Data processing method and device, equipment and storage medium

CN117473966BActive Publication Date: 2026-09-22CHINA CONSTRUCTION BANK +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311436127.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-31
Publication Date
2026-09-22
Estimated Expiration
2043-10-31

AI Technical Summary

Technical Problem

[0005]本申请提供一种数据处理方法、装置、设备及存储介质,用以解决现有技术中将数据导出为电子表格或将数据从电子表格导出时效率低下或错误率高的问题

Benefits of technology

[0067]本申请提供的数据处理方法、装置、设备及存储介质,通过获取用户触发的数据导出请求;所述数据导出请求包括用户从多个预设导出策略中选择的目标导出策略;所述目标导出策略包括原始数据库标识、目标电子表格类型标识、目标电子表格中的至少一个目标字段标识、各目标字段标识对应在原始数据库中的至少一个原始字段标识、各目标字段和各原始字段的字段类型、一个目标字段标识对应多个原始字段标识时的第一数据处理策略;根据原始字段的字段类型和原始字段对应的目标字段的字段类型,确定各原始字段对应的数据类型转换函数;按照第一预设数量依次从原始数据库中获取各原始字段下的原始数据;响应于目标字段对应一个原始字段,采用原始字段对应的数据类型转换函数,对原始数据进行字段类型转换,并将转换后的原始数据确定为原始数据对应在目标字段下的目标数据;响应于目标字段对应多个原始字段,采用各原始字段对应的数据类型转换函数,对各原始数据进行字段类型转换,并采用目标字段对应的第一数据处理策略对转换后的多个原始数据进行处理,获得多个原始数据对应在目标字段下目标数据;根据目标电子表格类型标识创建目标电子表格,创建向目标电子表格输出数据的文件输出流,并采用文件输出流将各原始数据对应在目标字段下的目标数据写入目标电子表格;响应于原始数据库中各原始字段下的原始数据对应在目标字段下的目标数据均被写入目标电子表格,输出目标电子表格的下载链接。由于用户可以从多个预设导出策略中选择的目标导出策略,而目标导出策略中包括原始字段标识、目标字段标识、原始字段与目标字段的对应关系、目标字段对应的第一数据处理策略等,因此,用户在从不同的数据库中导出不同的数据,将数据导出为不同形式、不同格式时,可以根据需要选择导出策略,而不需要修改导出数据的代码,进而,可以提高数据导出效率。同时,由于根据原始字段的字段类型和原始字段对应的目标字段的字段类型,确定各原始字段对应的数据类型转换函数,并采用原始字段对应的数据类型转换函数,对原始数据进行字段类型转换,因此,无论是在目标字段对应一个原始数据时,直接将转换后的数据确定为目标数据,还是在目标字段对应多个原始数据时,采用目标字段对应的第一数据处理策略对转换后的多个原始数据进行处理,获得多个原始数据对应在目标字段下目标数据。所获得的目标数据的字段类型都为目标字段的字段类型,因此,目标数据在目标电子表格中不会出现显示错误,可以确保数据处理的准确率。综上,本申请提供的数据处理方法,可以高效且准确地将数据库中的数据导出为电子表格。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117473966B_ABST
    Figure CN117473966B_ABST
Patent Text Reader

Abstract

The application provides a data processing method, device and equipment and a storage medium. It relates to the technical field of computers and data processing. The method comprises the following steps: obtaining a data export request triggered by a user and comprising a target export strategy; the target export strategy comprises at least one original field corresponding to each target field, the field types of each target field and each original field, and a first data processing strategy when one target field corresponds to multiple original fields; determining the data type conversion function of each original field; when one target field corresponds to one original field, determining target data by performing field type conversion on original data; when one target field corresponds to multiple original fields, determining target data by performing field type conversion on each original data and processing by using the corresponding first data processing strategy; and writing each target data into a target electronic form by using a file output stream. The method of the application can efficiently and accurately export data in a database into an electronic form.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer and data processing technology, and in particular to a data processing method, apparatus, device and storage medium. Background Technology

[0002] Spreadsheets are a widely used data visualization and analysis tool. Users can export data from a database to a spreadsheet for visualization and analysis. Users can also export data from a spreadsheet and import it into a database for storage.

[0003] Currently, both exporting data to and from spreadsheets involve looping through the data. Therefore, changes in data types, database types, and spreadsheets require significant time to adapt the code that iterates through the data, leading to inefficient data export and import processes. Conversely, without such adaptation, the same code will encounter numerous errors when dealing with different data types, database types, and spreadsheets, especially if field types are incompatible. This forces users to re-verify the exported or imported data, resulting in a poor user experience.

[0004] In summary, existing technologies suffer from inefficiency or high error rates when exporting data to or from spreadsheets. Summary of the Invention

[0005] This application provides a data processing method, apparatus, device, and storage medium to solve the problems of low efficiency or high error rate when exporting data to spreadsheets or from spreadsheets in the prior art.

[0006] Firstly, this application provides a data processing method, including:

[0007] Obtain a data export request triggered by the user; the data export request includes a target export strategy selected by the user from multiple preset export strategies; the target export strategy includes an original database identifier, a target spreadsheet type identifier, at least one target field identifier in the target spreadsheet, at least one original field identifier in the original database corresponding to each target field identifier, the field types of each target field and each original field, and a first data processing strategy when one target field identifier corresponds to multiple original field identifiers;

[0008] Based on the field type of the original field and the field type of the target field corresponding to the original field, determine the data type conversion function corresponding to each original field;

[0009] According to the first preset quantity, the original data under each original field is retrieved sequentially from the original database;

[0010] In response to the target field corresponding to an original field, the data type conversion function corresponding to the original field is used to convert the field type of the original data, and the converted original data is determined as the target data under the target field corresponding to the original data.

[0011] In response to the target field corresponding to multiple original fields, the data type conversion function corresponding to each original field is used to convert the field type of each original data, and the first data processing strategy corresponding to the target field is used to process the converted multiple original data to obtain the target data corresponding to the multiple original data under the target field;

[0012] Create a target spreadsheet based on the target spreadsheet type identifier, create a file output stream to output data to the target spreadsheet, and use the file output stream to write the target data corresponding to each original data under the target field into the target spreadsheet.

[0013] In response to the original data under each original field in the original database, the target data under the target field is written into the target spreadsheet, and a download link for the target spreadsheet is output.

[0014] In one possible design, determining the data type conversion function corresponding to each original field based on the field type of the original field and the field type of the target field corresponding to the original field includes:

[0015] Obtain the mapping relationship between multiple preset types of the original field and multiple preset types of the target field and multiple preset type conversion functions;

[0016] From the mapping relationship between multiple preset types of the original field and multiple preset types of the target field and multiple preset type conversion functions, determine the data type conversion function corresponding to each original field; the data type conversion function corresponding to the original field has a mapping relationship with the field type of the original field, and also has a mapping relationship with the field type of the target field corresponding to the original field.

[0017] In one possible design, the use of the data type conversion function corresponding to the original field to perform field type conversion on the original data includes:

[0018] Input the original data into the data type conversion function corresponding to the original field;

[0019] Use the data type conversion function corresponding to the original field of the original data to output the converted original data.

[0020] In one possible design, the first data processing strategy corresponding to the target field includes: a first merging strategy for multiple original data;

[0021] The first data processing strategy corresponding to the target field is used to process the transformed multiple original data to obtain the target data corresponding to the target field, including:

[0022] Using the first merging strategy, multiple transformed original data are merged to obtain multiple processed original data.

[0023] In one possible design, the target derivation strategy further includes: a second data processing strategy for each target field when multiple target field identifiers correspond to one original field identifier;

[0024] After retrieving the original data under each original field from the original database in sequence according to the first preset quantity, the process further includes:

[0025] In response to the fact that multiple target field identifiers correspond to one original field identifier, the data type conversion function corresponding to the original field is used to convert the field type of the original data;

[0026] The transformed original data is processed using the second data processing strategy corresponding to each target field to obtain the target data corresponding to each target field.

[0027] In one possible design, the second data processing strategy includes: a first splitting strategy for the original data;

[0028] The process of using a second data processing strategy corresponding to each target field to process the transformed original data to obtain the target data corresponding to each target field includes:

[0029] The original data after transformation is split using the first splitting strategy corresponding to each target field to obtain the target data corresponding to each target field.

[0030] Secondly, this application provides a data processing method, including:

[0031] Obtain a data import request triggered by the user; the data import request includes the file path of the original spreadsheet to be imported, the target import strategy selected by the user from multiple preset import strategies; the target import strategy includes: target database identifier, type identifier of the original spreadsheet, at least one original field identifier in the original spreadsheet, at least one target field identifier in the target database corresponding to each original field identifier, field type of each target field and each original field, and a third data processing strategy when one target field identifier corresponds to multiple original field identifiers;

[0032] Based on the field type of the original field and the field type of the target field corresponding to the original field, determine the data type conversion function corresponding to each original field;

[0033] According to the second preset quantity, retrieve the original data under each original field from the original spreadsheet in sequence;

[0034] In response to the target field corresponding to an original field, the data type conversion function corresponding to the original field is used to convert the field type of the original data, and the converted original data is determined as the target data under the target field corresponding to the original data.

[0035] In response to the target field corresponding to multiple original fields, the data type conversion function corresponding to each original field is used to convert the field type of each original data, and the third data processing strategy corresponding to the target field is used to process the converted multiple original data to obtain the target data corresponding to the multiple original data under the target field;

[0036] Create a file output stream to output data to the target database, and use the file output stream to write the target data corresponding to each original data under the target field into the target database;

[0037] In response to the fact that the original data under each original field in the original spreadsheet has been written to the target database, an import completion message is output.

[0038] In one possible design, the target import strategy further includes: the number of header rows;

[0039] The step of sequentially retrieving the original data under each original field from the original spreadsheet according to the second preset quantity includes:

[0040] Determine the starting row number for retrieving the original data based on the number of header rows;

[0041] Starting from the initial row number, retrieve the original data for each target field sequentially according to the second preset quantity.

[0042] In one possible design, the target import strategy further includes: a fourth data processing strategy for each target field when multiple target field identifiers correspond to one original field identifier;

[0043] After obtaining the original data under each original field from the original spreadsheet in sequence according to the second preset quantity, the process further includes:

[0044] In response to the fact that multiple target field identifiers correspond to one original field identifier, the data type conversion function corresponding to the original field is used to convert the field type of the original data;

[0045] The transformed original data is processed using the fourth data processing strategy corresponding to each target field to obtain the target data corresponding to each target field.

[0046] Thirdly, this application provides a data processing apparatus, comprising:

[0047] The first acquisition module is used to acquire a data export request triggered by the user; the data export request includes a target export strategy selected by the user from multiple preset export strategies; the target export strategy includes an original database identifier, a target spreadsheet type identifier, at least one target field identifier in the target spreadsheet, at least one original field identifier in the original database corresponding to each target field identifier, the field types of each target field and each original field, and a first data processing strategy when one target field identifier corresponds to multiple original field identifiers;

[0048] The determination module is used to determine the data type conversion function corresponding to each original field based on the field type of the original field and the field type of the target field corresponding to the original field;

[0049] The second acquisition module is used to sequentially acquire the original data under each original field from the original database according to the first preset quantity;

[0050] The conversion module is used to convert the field type of the original data in response to the target field corresponding to an original field, using the data type conversion function corresponding to the original field, and then determining the converted original data as the target data under the target field corresponding to the original data.

[0051] The first processing module is used to respond to multiple original fields corresponding to the target field, use the data type conversion function corresponding to each original field to convert the field type of each original data, and use the first data processing strategy corresponding to the target field to process the multiple original data after conversion, so as to obtain the target data corresponding to the multiple original data under the target field;

[0052] The first writing module is used to create a target spreadsheet according to the target spreadsheet type identifier, create a file output stream to output data to the target spreadsheet, and use the file output stream to write the target data corresponding to each original data under the target field into the target spreadsheet.

[0053] The first output module is used to respond to the fact that the target data corresponding to the original data under each original field in the original database has been written into the target spreadsheet, and outputs the download link of the target spreadsheet.

[0054] Fourthly, this application provides a data processing apparatus, comprising:

[0055] The third acquisition module is used to acquire a data import request triggered by the user. The data import request includes the file path of the original spreadsheet to be imported and the target import strategy selected by the user from multiple preset import strategies. The target import strategy includes: target database identifier, type identifier of the original spreadsheet, at least one original field identifier in the original spreadsheet, at least one target field identifier in the target database corresponding to each original field identifier, field type of each target field and each original field, and a third data processing strategy when one target field identifier corresponds to multiple original field identifiers.

[0056] The determination module is used to determine the data type conversion function corresponding to each original field based on the field type of the original field and the field type of the target field corresponding to the original field;

[0057] The fourth acquisition module is used to sequentially acquire the original data under each original field from the original spreadsheet according to the second preset quantity;

[0058] The conversion module is used to convert the field type of the original data in response to the target field corresponding to an original field, using the data type conversion function corresponding to the original field, and then determining the converted original data as the target data under the target field corresponding to the original data.

[0059] The second processing module, in response to the target field corresponding to multiple original fields, uses the data type conversion function corresponding to each original field to perform field type conversion on each original data, and uses the third data processing strategy corresponding to the target field to process the multiple original data after conversion, so as to obtain the target data corresponding to the multiple original data under the target field;

[0060] The second writing module creates a file output stream to output data to the target database, and uses the file output stream to write the target data corresponding to each original data under the target field into the target database.

[0061] The second output module, in response to the fact that the original data under each original field in the original spreadsheet has been written to the target database, outputs an import completion prompt message.

[0062] Fifthly, embodiments of this application provide an electronic device, including: a processor, and a memory communicatively connected to the processor;

[0063] The memory stores computer-executed instructions;

[0064] The processor executes computer execution instructions stored in the memory to implement the data processing method described in the first aspect, the second aspect, various possible implications of the first aspect, and various possible designs of the second aspect.

[0065] In a sixth aspect, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the data processing method described in the first aspect, the second aspect, various possible implications of the first aspect, and various possible designs of the second aspect.

[0066] In a seventh aspect, embodiments of this application provide a computer program product, including a computer program, which, when executed by a processor, is used to implement the data processing method described in the first aspect, the second aspect, various possible implications of the first aspect, and various possible designs of the second aspect.

[0067] The data processing method, apparatus, device, and storage medium provided in this application obtain a data export request triggered by a user. The data export request includes a target export strategy selected by the user from multiple preset export strategies. The target export strategy includes an original database identifier, a target spreadsheet type identifier, at least one target field identifier in the target spreadsheet, at least one original field identifier in the original database corresponding to each target field identifier, the field types of each target field and each original field, and a first data processing strategy when one target field identifier corresponds to multiple original field identifiers. Based on the field type of the original field and the field type of the target field corresponding to the original field, a data type conversion function corresponding to each original field is determined. The original data under each original field is sequentially obtained from the original database according to a first preset quantity. In response to a target field corresponding to an original field, the original field is used to... The system uses the corresponding data type conversion function to convert the field types of the original data and determines the converted original data as the target data corresponding to the target field. Since the target field corresponds to multiple original fields, it uses the data type conversion function corresponding to each original field to convert the field types of each original data, and uses the first data processing strategy corresponding to the target field to process the converted multiple original data to obtain the target data corresponding to the target field. It creates a target spreadsheet based on the target spreadsheet type identifier, creates a file output stream to output data to the target spreadsheet, and uses the file output stream to write the target data corresponding to the target field of each original data to the target spreadsheet. Finally, since the target data corresponding to the original data in each original field of the original database has been written to the target spreadsheet, it outputs a download link for the target spreadsheet. Because users can choose from multiple preset export strategies, and each target export strategy includes original field identifiers, target field identifiers, the correspondence between original and target fields, and the first data processing strategy corresponding to the target field, users can select the appropriate export strategy when exporting different data from different databases and in different formats without modifying the data export code, thus improving data export efficiency. Furthermore, since the data type conversion function for each original field is determined based on its type and the corresponding target field type, and this function is used to convert the original data's field type, the converted data can be directly identified as the target data whether the target field corresponds to a single original data point, or the first data processing strategy corresponding to the target field is used to process the converted original data to obtain the target data corresponding to the target field when the target field corresponds to multiple original data points.The field types of the obtained target data are all of the target field type; therefore, the target data will not display incorrectly in the target spreadsheet, ensuring the accuracy of data processing. In summary, the data processing method provided in this application can efficiently and accurately export data from a database to a spreadsheet. Attached Figure Description

[0068] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0069] Figure 1 Network architecture diagram corresponding to the application scenario of the data processing method provided in the embodiments of this application;

[0070] Figure 2 A flowchart illustrating the data processing method provided in Embodiment 1 of this application;

[0071] Figure 3 A flowchart illustrating the data processing method provided in Embodiment 2 of this application;

[0072] Figure 4 This is a schematic diagram of the data processing apparatus provided in Embodiment 3 of this application;

[0073] Figure 5 This is a schematic diagram of the data processing apparatus provided in Embodiment 4 of this application;

[0074] Figure 6 This is a schematic diagram of the structure of the electronic device provided in Embodiment 5 of this application.

[0075] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation

[0076] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0077] Currently, both exporting data to and from spreadsheets involve looping through the data. This involves repeatedly reading data from the database and writing it to the spreadsheet, and vice versa. If the data type changes, developers must adapt the code, leading to inefficient data export and import processes. Conversely, without adapting the code, using the same code to read and write different data types—for example, data stored as a string in the database but as a date in the spreadsheet—indicates display errors. This forces users to re-check the exported or imported data, resulting in a poor user experience.

[0078] In summary, existing technologies suffer from inefficiency or high error rates when exporting data to or from spreadsheets.

[0079] To address the aforementioned technical problems, this application proposes the following technical concept: Pre-defined import / export strategies are built for different databases and table formats. Users can select the corresponding strategy when importing or exporting data without modifying the code. Simultaneously, data type conversion is added to the import and export strategies to convert the read data into the data type required for writing, preventing data display errors after writing. In this way, the problems in existing technologies can be solved while ensuring both efficiency and accuracy when exporting data to or from spreadsheets.

[0080] Figure 1 This is a network architecture diagram corresponding to the application scenario of the data processing method provided in the embodiments of this application. For example... Figure 1 As shown, this application scenario includes: an electronic device 10, a user terminal 11, a raw database 12, and a target spreadsheet 13. The electronic device 10 is communicatively connected to the user terminal 11 and the raw database 12. The raw database 12 includes multiple raw fields, and the target spreadsheet 13 includes multiple target fields.

[0081] In one application scenario, electronic device 10 is equipped with a data processing service, and user terminal 11 is equipped with a client application software for the data processing service, or user terminal 11 accesses the URL of the data processing service. The user selects a target export strategy from multiple preset export strategies through the client's operation interface or the webpage corresponding to the URL, and triggers a data export request.

[0082] After the user triggers a data export request, the user terminal 11 sends the user-triggered data export request to the electronic device 10, and the electronic device 10 receives the user-triggered data export request. The data export request includes a target export strategy selected by the user from multiple preset export strategies; the target export strategy includes an original database identifier, a target spreadsheet type identifier, at least one target field identifier in the target spreadsheet, at least one original field identifier in the original database corresponding to each target field identifier, the field types of each target field and each original field, and a first data processing strategy when one target field identifier corresponds to multiple original field identifiers.

[0083] Electronic device 10 determines the data type conversion function corresponding to each original field based on the field type of the original field and the field type of the target field corresponding to the original field.

[0084] Electronic device 10 can access original database 12 according to original database identifier, and sequentially retrieve original data under each original field from original database 12 according to a first preset number.

[0085] In response to a target field corresponding to an original field, the electronic device 10 uses the data type conversion function corresponding to the original field to perform field type conversion on the original data, and determines the converted original data as the target data corresponding to the original data under the target field.

[0086] In response to the target field corresponding to multiple original fields, the electronic device 10 uses the data type conversion function corresponding to each original field to convert the field type of each original data, and uses the first data processing strategy corresponding to the target field to process the converted multiple original data to obtain the target data corresponding to the multiple original data under the target field.

[0087] Electronic device 10 can create target spreadsheet 13 according to target spreadsheet type identifier, create file output stream to output data to target spreadsheet 13, and use file output stream to write target data corresponding to each original data under target field into target spreadsheet.

[0088] In response to the original data in each original field of the original database 12 being written into the target spreadsheet 13, spreadsheet 10 sends a download link for the target spreadsheet 13 to the user terminal so that the user terminal 11 can display the download link.

[0089] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.

[0090] Example 1

[0091] Figure 2 This is a flowchart illustrating the data processing method provided in Embodiment 1 of this application. Figure 2 As shown, the execution subject of this embodiment is a data processing device, which is located in an electronic device. The data processing method provided in this embodiment includes steps 201 to 207.

[0092] Step 201: Obtain the data export request triggered by the user; the data export request includes the target export strategy selected by the user from multiple preset export strategies; the target export strategy includes the original database identifier, the target spreadsheet type identifier, at least one target field identifier in the target spreadsheet, at least one original field identifier in the original database corresponding to each target field identifier, the field type of each target field and each original field, and a first data processing strategy when one target field identifier corresponds to multiple original field identifiers.

[0093] In this embodiment, the user is someone who needs to export raw data from the original database to target data in a target spreadsheet. The user terminal is a user-operable device. The user terminal has a client application software for data processing services installed on it, or the user terminal accesses a website address for data processing services. The client's interface or the webpage corresponding to the website address can display multiple preset export strategies. The user can select a target export strategy on the client's interface or the webpage corresponding to the website address and trigger a data export request through the "OK" component. The user terminal receives the data export request triggered by the user and sends it to the electronic device. The electronic device receives the data export request triggered by the user.

[0094] The target field corresponds to the original field in the original database and is the data source of the target field. When one target field identifier corresponds to multiple original field identifiers, it means that the target field is related to multiple original fields, for example, it can be obtained by merging or calculating multiple original fields.

[0095] For example, if the target field is name, and the corresponding two original fields are surname and given name, then the target data under the target field can be formed by combining the original data under the surname field and the original data under the given name field.

[0096] For example, if the target field is the annual total, and the corresponding original fields are the total for the first quarter, the total for the second quarter, the total for the third quarter, and the total for the fourth quarter, then the target data under the target field can be obtained by summing the original data under the total for the first quarter, the total for the second quarter, the total for the third quarter, and the total for the fourth quarter.

[0097] Step 202: determining the data type conversion function corresponding to each original field according to the field type of the original field and the field type of the target field corresponding to the original field.

[0098] In this embodiment, there are multiple types of original fields and multiple types of target fields. Therefore, converting original data of different field types to different field types requires different data type conversion functions.

[0099] Optionally, step 202 is refined to include step 2021 to step 2022.

[0100] Step 2021: acquiring the mapping relationship among a plurality of preset types of original fields, a plurality of preset types of target fields and a plurality of preset type conversion functions.

[0101] In this embodiment, the plurality of preset types of original fields may include: integer type, floating point type, string type, date type, enumeration type, etc.

[0102] The plurality of preset types of target fields may include: date type, string type, number type, enumeration type, Boolean type, etc.

[0103] Wherein, the integer type may include tiny integer, short integer, medium integer, standard integer, and big integer. The floating point type may include single-precision floating point and double-precision floating point. The string type may include fixed-length type and variable-length type. The string type includes ordinary characters and binary characters.

[0104] The mapping relationship is used for determining, according to the field type of the original field and the field type of the target field, the data type conversion function for converting the field type of the original field into the field type of the target field. For example, converting 12345 of integer type into 12345 of string type; converting a date type in yyyy.mm.dd format into a date type in yyyy-mm-dd format; converting a date type in yyyy.mm.dd format into a string type in the format of yyyy year mm month dd day.

[0105] Step 2022: determining, from the mapping relationship among the plurality of preset types of original fields, the plurality of preset types of target fields and the plurality of preset type conversion functions, the data type conversion function corresponding to each original field; the data type conversion function corresponding to the original field has a mapping relationship with the field type of the original field, and has a mapping relationship with the field type of the target field corresponding to the original field.

[0106] In this embodiment, the electronic device can use the field types of the original field and the target field as keywords to query multiple mapping relationships and obtain a preset type conversion function that has a mapping relationship with both the field types of the original field and the target field. This preset type conversion function can be used to perform mutual conversion between the field types of the original field and the target field. Therefore, the electronic device can determine the preset type conversion function that has a mapping relationship with both the field types of the original field and the target field as the data type conversion function corresponding to the original field.

[0107] Step 203: Obtain the original data under each original field from the original database in sequence according to the first preset quantity.

[0108] In this embodiment, the first preset quantity can be set according to the performance of the electronic device or the original database, so that when too much data is exported, the electronic device can read the original data from the original database in batches, avoiding the electronic device or the original database from having too long a response time or being unable to respond.

[0109] Step 204: In response to the target field corresponding to an original field, the data type conversion function corresponding to the original field is used to convert the field type of the original data, and the converted original data is determined as the target data under the target field corresponding to the original data.

[0110] In this embodiment, the target field corresponds to a single original field, indicating that the data source for the target field is only one original field. Therefore, by simply converting the original data under the original field to the field type of the target field, the converted original data can be identified as the target data, avoiding display errors caused by field type mismatch after data export. Thus, the electronic device can use the data type conversion function corresponding to the original field to perform field type conversion on the original data, and identify the converted original data as the target data under the target field corresponding to the original field.

[0111] Optionally, step 204 may be further refined to include steps 2041 to 2042.

[0112] Step 2041: Input the original data into the data type conversion function corresponding to the original field.

[0113] In this embodiment, the electronic device can call the data type conversion function corresponding to the original field to which the original data belongs, and input the original data into the data type conversion function.

[0114] Step 2042. Use the data type conversion function corresponding to the original field of the original data to output the converted original data.

[0115] In this embodiment, the data type conversion function performs data type conversion on the input raw data and outputs the converted raw data. The field type of the converted raw data is the field type of the target field corresponding to the original field.

[0116] Step 205: In response to the target field corresponding to multiple original fields, the data type conversion function corresponding to each original field is used to convert the field type of each original data, and the first data processing strategy corresponding to the target field is used to process the converted multiple original data to obtain the target data corresponding to the multiple original data under the target field.

[0117] In this embodiment, if a target field corresponds to multiple original fields, it indicates that the data source of the target field is multiple original fields. When a target field corresponds to multiple original fields, the export strategy includes a first data processing strategy corresponding to the target field. The first data processing strategy is preset based on the target field identifier and the multiple original field identifiers corresponding to the target field identifier. For example, if the target field identifier is an annual total and the multiple original field identifiers are the totals for January to December, then the first data processing strategy corresponding to the target field identifier is to sum the original data under the multiple original fields; if the target field identifier is an annual average and the multiple original fields are the totals for January to December, then the first data processing strategy corresponding to the target field identifier is to sum the original data under the multiple original fields and then divide by 12.

[0118] Optionally, the first data processing strategy corresponding to the target field includes: a first merging strategy for multiple raw data. Step 205, "processing the multiple converted raw data using the first data processing strategy corresponding to the target field to obtain the target data corresponding to the multiple raw data under the target field," is further refined to include: merging the multiple converted raw data using the first merging strategy to obtain the processed data of the multiple raw data.

[0119] In this embodiment, the first merging strategy can be to concatenate multiple original data in a preset order. For example, if the target field is year, month, and day, corresponding to three original fields: year, month, and day, then the first merging strategy for the target field is to concatenate the original data under the year, month, and day in sequence.

[0120] In this embodiment, in order to ensure that the field types of the merged target data are accurate and that there are no display errors in the target spreadsheet, the field types of the original data are first converted, and then the converted original data is merged.

[0121] Step 206: Create a target spreadsheet based on the target spreadsheet type identifier, create a file output stream to output data to the target spreadsheet, and use the file output stream to write the target data corresponding to each original data under the target field into the target spreadsheet.

[0122] In this embodiment, different target spreadsheet type identifiers correspond to different types of spreadsheets, and different types of spreadsheets can have different formats. Therefore, the electronic device can create a target spreadsheet based on the target spreadsheet type identifier in the target export strategy. Furthermore, after the target spreadsheet is created, a file output stream can be created to output data to the target spreadsheet.

[0123] Optionally, step 206 may further include: closing the file output stream in response to at least one of the file output stream exception event and the original database exception event.

[0124] In this embodiment, if the original database is unresponsive for a long time and the electronic device cannot obtain the original data from the original database, an original database exception event will be triggered. If the file output stream is abnormal, a file output stream exception event will be triggered. At this time, the electronic device can close the file output stream to avoid the file output stream occupying resources for a long time.

[0125] Step 207: In response to the original data under each original field in the original database corresponding to the target data under the target field being written into the target spreadsheet, output the download link of the target spreadsheet.

[0126] In this embodiment, the electronic device can sequentially obtain a first preset number of original data under each original field from the original database through an iterative process, determine the target data corresponding to each original data, and write the target data into the target spreadsheet. After the electronic device determines that the target data corresponding to the original data under each original field in the original database has been written into the target spreadsheet, the data export is complete. The electronic device can output the download link of the target spreadsheet, for example, by sending it to the user terminal, so that the user can access the download link of the target spreadsheet through the user terminal to download the target spreadsheet.

[0127] In this embodiment, the target spreadsheet created by the electronic device can be located in its own storage space or in a preset file storage server, and the download link of the target spreadsheet can be the spreadsheet's Uniform Resource Locator.

[0128] The data processing method provided in this embodiment obtains a data export request triggered by a user. The data export request includes a target export strategy selected by the user from multiple preset export strategies. The target export strategy includes an original database identifier, a target spreadsheet type identifier, at least one target field identifier in the target spreadsheet, at least one original field identifier in the original database corresponding to each target field identifier, the field types of each target field and each original field, and a first data processing strategy when one target field identifier corresponds to multiple original field identifiers. Based on the field type of the original field and the field type of the target field corresponding to the original field, the data type conversion function corresponding to each original field is determined. The original data under each original field is sequentially obtained from the original database according to a first preset quantity. In response to a target field corresponding to an original field, the data type conversion function corresponding to the original field is applied. The system performs a conversion function to transform the field types of the original data and identifies the transformed original data as the target data corresponding to the target field. Responding to the fact that the target field corresponds to multiple original fields, it uses the data type conversion function corresponding to each original field to transform the field types of each original data. It then uses the first data processing strategy corresponding to the target field to process the transformed multiple original data, obtaining the target data corresponding to the multiple original data under the target field. A target spreadsheet is created based on the target spreadsheet type identifier. A file output stream is created to output data to the target spreadsheet, and the file output stream is used to write the target data corresponding to each original data under the target field into the target spreadsheet. Finally, in response to the fact that the target data corresponding to each original data under each original field in the original database has been written into the target spreadsheet, a download link for the target spreadsheet is output. Because users can choose from multiple preset export strategies, and each target export strategy includes original field identifiers, target field identifiers, the correspondence between original and target fields, and the first data processing strategy corresponding to the target field, users can select the appropriate export strategy when exporting different data from different databases and in different formats without modifying the export code, thus improving data export efficiency. Furthermore, since the data type conversion function for each original field is determined based on its type and the corresponding target field type, and this function is used to convert the field types of the original data, whether the target field corresponds to a single original data point and the converted data is directly used as the target data, or the target field corresponds to multiple original data points and the first data processing strategy corresponding to the target field is used to process the converted original data, resulting in target data corresponding to the target field, the field types of the obtained target data are all the same as those of the target field. Therefore, the target data will not display incorrectly in the target spreadsheet, ensuring the accuracy of data processing.In summary, the data processing method provided in this application can efficiently and accurately export data from a database into a spreadsheet.

[0129] Optionally, the target export strategy also includes a second data processing strategy for each target field when multiple target field identifiers correspond to one original field identifier. After step 203 "retrieves the original data under each original field from the original database in sequence according to the first preset quantity", steps 301 to 302 are also included.

[0130] Step 301: In response to the fact that multiple target field identifiers correspond to one original field identifier, the data type conversion function corresponding to the original field is used to convert the field type of the original data.

[0131] Step 302: The transformed original data is processed using the second data processing strategy corresponding to each target field to obtain the target data corresponding to each target field of the original data.

[0132] In this embodiment, when multiple target field identifiers correspond to one original field identifier, it means that the data source of these multiple target fields is the same original field, and the original data under this original field can be processed into target data under multiple target fields.

[0133] For example, the original field identifier can be an annual total, and the corresponding multiple target field identifiers can be quarterly average, monthly average, and daily average, respectively. Then, the second data processing strategies corresponding to the quarterly average, monthly average, and daily average are the original data divided by 4, the original data divided by 12, and the original data divided by 365, respectively.

[0134] In this embodiment, in order to ensure that the target data is displayed correctly in the target spreadsheet, the electronic device needs to use the data type conversion function corresponding to the original field to convert the field type of the original data, and then use the second data processing strategy corresponding to each target field to process the converted original data.

[0135] Optionally, the second data processing strategy includes: a first splitting strategy for the original data. Step 302, "processing the transformed original data using the second data processing strategy corresponding to each target field to obtain the target data corresponding to each target field of the original data," is further refined to include step 3021.

[0136] Step 3021: Using the first splitting strategy corresponding to each target field, the transformed original data is split to obtain the target data corresponding to each target field of the original data.

[0137] In this embodiment, the first splitting strategy corresponding to each target field can split the original data into multiple target data.

[0138] For example, the original field can be year, month and day, and the corresponding multiple target fields can be year, month and day. The year, month and day fields can correspond to different first splitting strategies. The original data "yyyy-mm-dd" under the original field can be split into the year field "yyyy", the month field "mm" and the day field "dd" by the first splitting strategy corresponding to the year, month and day fields.

[0139] For example, the first splitting strategy corresponding to the year field may be determining the string before the character "year" as the target data, the first splitting strategy corresponding to the month field may be determining the string between the character "year" and the character "month" as the target data, and the first splitting strategy corresponding to the day field may be determining the string between the character "month" and the character "day" as the target data.

[0140] In the data processing method provided by this embodiment, when a plurality of target field identifiers correspond to one original field identifier, each target field corresponds to a second data processing strategy, so that when data is exported, the original field can be exported as a plurality of target fields, which improves the data processing efficiency.

[0141] Embodiment 2

[0142] Figure 3 is a schematic flow diagram of the data processing method provided by the second embodiment of the present application. As Figure 3 shown, the execution subject of this embodiment is a data processing apparatus, which is located in an electronic device. The data processing method provided by this embodiment includes step 401 to step 407.

[0143] Step 401: acquiring a data import request triggered by a user, where the data import request comprises a file path of an original spreadsheet to be imported and a target import strategy selected by the user from a plurality of preset import strategies. The target import strategy comprises: a target database identifier, a type identifier of the original spreadsheet, at least one original field identifier in the original spreadsheet, at least one target field identifier in the target database corresponding to each original field identifier, field types of each target field and each original field, and a third data processing strategy when one target field identifier corresponds to a plurality of original field identifiers.

[0144] Step 402: determining a data type conversion function corresponding to each original field according to the field type of the original field and the field type of the target field corresponding to the original field.

[0145] In this embodiment, referring to the description in Embodiment 1, the user terminal may have a client application for data processing service software installed, or the user terminal may access a URL for data processing service. The client's interface or the webpage corresponding to the URL may display multiple preset import strategies. The user can select a target import strategy on the client's interface or the webpage corresponding to the URL, and can also input the file path of the original spreadsheet to be imported.

[0146] Step 403: Obtain the original data under each original field from the original spreadsheet in sequence according to the second preset quantity.

[0147] In this embodiment, the second preset quantity can be set based on the size of the original spreadsheet and the performance of the electronic device. The size of the original spreadsheet reflects the amount of data stored in it. Different original spreadsheet type identifiers correspond to different types of spreadsheets, and different types of spreadsheets can have different formats. The original spreadsheet type identifier is used to identify the type of the original spreadsheet to be imported. The electronic device obtains the original spreadsheet from its file path, determines the method of reading raw data from the original spreadsheet based on the original spreadsheet type identifier, and sequentially reads the raw data under each raw field in the original spreadsheet according to the second preset quantity.

[0148] Step 404: In response to the target field corresponding to an original field, the data type conversion function corresponding to the original field is used to convert the field type of the original data, and the converted original data is determined as the target data under the target field corresponding to the original data.

[0149] Step 405: In response to the target field corresponding to multiple original fields, the data type conversion function corresponding to each original field is used to convert the field type of each original data, and the third data processing strategy corresponding to the target field is used to process the converted multiple original data to obtain the target data corresponding to the multiple original data under the target field.

[0150] Step 406: Create a file output stream to output data to the target database, and use the file output stream to write the target data corresponding to each original data under the target field into the target database.

[0151] In this embodiment, the third data processing strategy is a strategy to process multiple original fields into target fields. For example, it can be to concatenate, sum, or average the original data under multiple original fields in order.

[0152] In this embodiment, the descriptions of determining the data type conversion function corresponding to each original field, converting the field type of the original data, creating a file output stream, and writing the target data into the target database can be found in Embodiment 1, and will not be repeated here.

[0153] Step 407: In response to the fact that the original data under each original field in the original spreadsheet has been written to the target database, an import completion message is output.

[0154] In this embodiment, if the original data under each original field in the original spreadsheet is written to the target database as target data under the target field, the electronic device can output an import completion prompt message to notify the user that the data import is complete. For example, the electronic device can send the import completion prompt message to the user terminal so that the user terminal can display the import completion prompt message to notify the user that the data import is complete.

[0155] The data processing method provided in this embodiment obtains a data import request triggered by a user. The data import request includes the file path of the original spreadsheet to be imported and the target import strategy selected by the user from multiple preset import strategies. The target import strategy includes: a target database identifier, a type identifier of the original spreadsheet, at least one original field identifier in the original spreadsheet, at least one target field identifier in the target database corresponding to each original field identifier, the field types of each target field and each original field, and a third data processing strategy when one target field identifier corresponds to multiple original field identifiers. Based on the field type of the original field and the field type of the target field corresponding to the original field, the data type conversion function corresponding to each original field is determined. The original data under each original field is sequentially obtained from the original spreadsheet according to a second preset quantity. In response to the target field... For a given original field, the data type conversion function corresponding to that field is used to convert the field type of the original data, and the converted original data is then identified as the target data corresponding to the original data under the target field. If the target field corresponds to multiple original fields, the data type conversion function corresponding to each original field is used to convert the field type of each original data, and the third data processing strategy corresponding to the target field is used to process the converted multiple original data to obtain the target data corresponding to the multiple original data under the target field. A file output stream is created to output data to the target database, and the file output stream is used to write the target data corresponding to each original data under the target field into the target database. In response to the fact that the target data under each original field in the original spreadsheet has been written to the target database, an import completion message is output. Since users can choose a target import strategy from multiple preset import strategies, and the target import strategy includes original field identifiers, target field identifiers, the correspondence between original and target fields, and the third data processing strategy corresponding to the target field, users can choose the import strategy as needed when importing data from different types of spreadsheets into the database without modifying the import data code, thus improving data export efficiency. Furthermore, since the data type conversion function for each original field is determined based on its field type and the corresponding target field's field type, and this function is used to convert the field types of the original data, the converted data is directly used as the target data regardless of whether the target field corresponds to a single original data point, or whether a third data processing strategy corresponding to the target field is used to process the converted original data points to obtain the target data corresponding to the target field. The field types of the obtained target data are all the same as those of the target field. Therefore, the target data will not display incorrectly in the target database, ensuring the accuracy of data processing.In summary, the data processing method provided in this application can efficiently and accurately import data from spreadsheets into a database.

[0156] Optionally, the target import strategy may also include: the number of header rows; step 403, "obtain the original data under each original field from the original spreadsheet in sequence according to the second preset number", may be further refined to include steps 4031 to 4032.

[0157] Step 4031: Determine the starting row number for obtaining the original data based on the number of header rows.

[0158] In this embodiment, since there is no data in the header, the electronic device can determine the starting row number for acquiring the original data as the header row number plus 1. For example, when there are 3 header rows, the starting row number for acquiring the original data is the 4th row.

[0159] Step 4032: Starting from the initial row number, retrieve the original data under each target field sequentially according to the second preset quantity.

[0160] In this embodiment, the electronic device can start from the starting row number of the original data acquisition and sequentially acquire the original data under each target field according to the second preset number.

[0161] The data processing method provided in this embodiment determines the starting row number for obtaining the original data based on the number of rows in the header. Starting from the starting row number, the original data under each target field is obtained sequentially according to a second preset quantity. Since there is no original data in the header, when importing data from a spreadsheet into a database, the header can be ignored, and the original data can be read directly from the starting row number of the original data without needing to process the header separately. Therefore, the efficiency of importing data from a spreadsheet into a database can be improved.

[0162] Optionally, the target import strategy also includes: a fourth data processing strategy for each target field when multiple target field identifiers correspond to one original field identifier; after step 403 "obtain the original data under each original field from the original spreadsheet in sequence according to the second preset quantity", steps 501 to 502 are also included.

[0163] Step 501: In response to the fact that multiple target field identifiers correspond to one original field identifier, the data type conversion function corresponding to the original field is used to convert the field type of the original data.

[0164] Step 502: The transformed original data is processed using the fourth data processing strategy corresponding to each target field to obtain the target data corresponding to each target field of the original data.

[0165] In this embodiment, when importing data from a spreadsheet into a database, there may be multiple target fields whose data sources are the same original field. In this case, the target import strategy also includes a fourth data processing strategy corresponding to each target field. The electronic device uses the fourth data processing strategy corresponding to each target field to process the original data under the same original field into target data under different target fields. For details, please refer to the example in Embodiment 1, which will not be elaborated here.

[0166] The data processing method provided in this embodiment also includes a fourth data processing strategy for each target field when multiple target field identifiers correspond to one original field identifier, so that the original field can be imported as multiple target fields, thereby improving data processing efficiency.

[0167] Example 3

[0168] Figure 4 This is a schematic diagram of the data processing apparatus provided in Embodiment 3 of this application. Figure 4 As shown, the data processing device 40 provided in this embodiment includes: a first acquisition module 41, a determination module 42, a second acquisition module 43, a conversion module 44, a first processing module 45, a first writing module 46, and a first output module 47.

[0169] The first acquisition module 41 is used to acquire a data export request triggered by the user. The data export request includes a target export strategy selected by the user from multiple preset export strategies. The target export strategy includes an original database identifier, a target spreadsheet type identifier, at least one target field identifier in the target spreadsheet, at least one original field identifier in the original database corresponding to each target field identifier, the field types of each target field and each original field, and a first data processing strategy when one target field identifier corresponds to multiple original field identifiers.

[0170] Module 42 is used to determine the data type conversion function corresponding to each original field based on the field type of the original field and the field type of the target field corresponding to the original field.

[0171] The second acquisition module 43 is used to sequentially acquire the original data under each original field from the original database according to the first preset quantity.

[0172] The conversion module 44 is used to convert the field type of the original data in response to the target field corresponding to an original field, using the data type conversion function corresponding to the original field, and then determining the converted original data as the target data corresponding to the original data under the target field.

[0173] The first processing module 45 is used to respond to multiple original fields corresponding to the target field, use the data type conversion function corresponding to each original field to convert the field type of each original data, and use the first data processing strategy corresponding to the target field to process the converted multiple original data to obtain the target data corresponding to the multiple original data under the target field.

[0174] The first writing module 46 is used to create a target spreadsheet according to the target spreadsheet type identifier, create a file output stream to output data to the target spreadsheet, and use the file output stream to write the target data corresponding to each original data under the target field into the target spreadsheet.

[0175] The first output module 47 is used to output a download link for the target spreadsheet in response to the fact that the target data corresponding to the original data under each original field in the original database has been written into the target spreadsheet.

[0176] Optionally, module 42 is specifically used for:

[0177] Obtain the mapping relationship between multiple preset types of the original field and multiple preset types of the target field and multiple preset type conversion functions;

[0178] From the mapping relationship between multiple preset types of the original field and multiple preset types of the target field and multiple preset type conversion functions, determine the data type conversion function corresponding to each original field; the data type conversion function corresponding to the original field has a mapping relationship with the field type of the original field, and also has a mapping relationship with the field type of the target field corresponding to the original field.

[0179] Optionally, the conversion module 44 and the first processing module 45 are specifically used for:

[0180] Input the original data into the data type conversion function corresponding to the original field;

[0181] Use the data type conversion function corresponding to the original field of the original data to output the converted original data.

[0182] Optionally, the first data processing strategy corresponding to the target field includes: a first merging strategy for multiple original data; the first processing module 45 is further used for:

[0183] The first merging strategy is adopted to merge multiple transformed original data to obtain multiple processed original data.

[0184] Optionally, the target export strategy further includes: a second data processing strategy for each target field when multiple target field identifiers correspond to one original field identifier; the first processing module 45 is further specifically used for:

[0185] In response to the fact that multiple target field identifiers correspond to one original field identifier, the data type conversion function corresponding to the original field is used to convert the field type of the original data;

[0186] The transformed original data is processed using the second data processing strategy corresponding to each target field to obtain the target data corresponding to each target field.

[0187] Optionally, the second data processing strategy includes: a first splitting strategy for the original data; the first processing module 45 is further specifically used for:

[0188] The original data after transformation is split using the first splitting strategy corresponding to each target field to obtain the target data corresponding to each target field.

[0189] The data processing device provided in this embodiment can execute any of the data processing methods provided in Embodiment 1 above. The specific implementation and principle are similar, and will not be described again here.

[0190] Example 4

[0191] Figure 5 This is a schematic diagram of the data processing apparatus provided in Embodiment 4 of this application. Figure 5 As shown, the data processing device 50 provided in this embodiment includes: a third acquisition module 51, a determination module 52, a fourth acquisition module 53, a conversion module 54, a second processing module 55, a second writing module 56, and a second output module 57.

[0192] The third acquisition module 51 is used to acquire the data import request triggered by the user. The data import request includes the file path of the original spreadsheet to be imported and the target import strategy selected by the user from multiple preset import strategies. The target import strategy includes: target database identifier, type identifier of the original spreadsheet, at least one original field identifier in the original spreadsheet, at least one target field identifier in the target database corresponding to each original field identifier, field type of each target field and each original field, and a third data processing strategy when one target field identifier corresponds to multiple original field identifiers.

[0193] The determination module 52 is used to determine the data type conversion function corresponding to each original field based on the field type of the original field and the field type of the target field corresponding to the original field.

[0194] The fourth acquisition module 53 is used to sequentially acquire the original data under each original field from the original spreadsheet according to the second preset quantity.

[0195] The conversion module 54 is used to convert the field type of the original data in response to the target field corresponding to an original field, using the data type conversion function corresponding to the original field, and then determining the converted original data as the target data corresponding to the original data under the target field.

[0196] The second processing module 55, in response to the target field corresponding to multiple original fields, uses the data type conversion function corresponding to each original field to perform field type conversion on each original data, and uses the third data processing strategy corresponding to the target field to process the converted multiple original data to obtain the target data corresponding to the multiple original data under the target field.

[0197] The second writing module 56 creates a file output stream for outputting data to the target database, and uses the file output stream to write the target data corresponding to each original data field into the target database.

[0198] The second output module 57 outputs an import completion message in response to the fact that the original data under each original field in the original spreadsheet has been written to the target database.

[0199] Optionally, the target import strategy also includes: the number of header rows; the fourth acquisition module 53 is specifically used for:

[0200] Determine the starting row number for retrieving the original data based on the number of header rows;

[0201] Starting from the initial row number, retrieve the original data for each target field sequentially according to the second preset quantity.

[0202] Optionally, the target import strategy also includes: a fourth data processing strategy for each target field when multiple target field identifiers correspond to one original field identifier; the second processing module 55 is further specifically used for:

[0203] In response to the fact that multiple target field identifiers correspond to one original field identifier, the data type conversion function corresponding to the original field is used to convert the field type of the original data;

[0204] The transformed original data is processed using the fourth data processing strategy corresponding to each target field to obtain the target data corresponding to each target field.

[0205] The data processing device provided in this embodiment can execute any of the data processing methods provided in Embodiment 2 above. The specific implementation method and principle are similar, and will not be described again here.

[0206] It should be noted that the division of the various modules in the above device is merely a logical functional division. In actual implementation, they can be fully or partially integrated into a single physical entity, or they can be physically separated. These modules can be implemented entirely in software via processing element calls; they can be fully implemented in hardware; or some modules can be implemented in software via processing element calls, while others are implemented in hardware. Each module can be a separate processing element, or it can be integrated into a chip within the device. Alternatively, it can be stored as program code in the device's memory, and its functions can be called and executed by a processing element. Furthermore, these modules can be fully or partially integrated together, or they can be implemented independently. The processing element here can be an integrated circuit with signal processing capabilities. During implementation, each step of the above method or each of the above modules can be completed through integrated logic circuits in the processor element or through software instructions.

[0207] Example 5

[0208] Figure 6 This is a schematic diagram of the structure of the electronic device provided in Embodiment 5 of this application. Figure 6 As shown, the electronic device 60 may include a processor 62 and a memory 61 communicatively connected to the processor 62.

[0209] Memory 61 stores computer-executed instructions.

[0210] The processor 62 executes the computer execution instructions stored in the memory 61 to implement the data processing method provided in any of the above embodiments. The specific implementation method and principle are similar and will not be described again here.

[0211] Optionally, the electronic device also includes a transceiver that is communicatively connected to the memory and processor for sending and receiving data.

[0212] The memory 61 and the processor 62 can communicate via a bus. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 6 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0213] Processor 62 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0214] This application also provides a chip for executing instructions, which is used to execute the data processing method described in the above embodiments.

[0215] This application also provides a computer-readable storage medium storing computer instructions that, when executed on a computer, cause the computer to perform the data processing method described in the above embodiments.

[0216] The aforementioned storage medium can be implemented from any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The storage medium can be any available medium accessible to general-purpose or special-purpose computers.

[0217] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the technical solution of the data processing method provided in any of the above embodiments. The specific implementation method and principle are similar and will not be repeated here.

[0218] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to this application.

[0219] It should be further noted that although the steps in the flowchart are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowchart may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.

[0220] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.

[0221] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

Claims

1. A data processing method, characterized in that, include: Retrieve the data export request triggered by the user; The data export request includes a target export strategy selected by the user from multiple preset export strategies; The target export strategy includes an original database identifier, a target spreadsheet type identifier, at least one target field identifier in the target spreadsheet, at least one original field identifier in the original database corresponding to each target field identifier, the field types of each target field and each original field, and a first data processing strategy when one target field identifier corresponds to multiple original field identifiers; Based on the field type of the original field and the field type of the target field corresponding to the original field, determine the data type conversion function corresponding to each original field; According to the first preset quantity, the original data under each original field is retrieved sequentially from the original database; In response to the target field corresponding to an original field, the data type conversion function corresponding to the original field is used to convert the field type of the original data, and the converted original data is determined as the target data under the target field corresponding to the original data. In response to the target field corresponding to multiple original fields, the data type conversion function corresponding to each original field is used to convert the field type of each original data, and the first data processing strategy corresponding to the target field is used to process the converted multiple original data to obtain the target data corresponding to the multiple original data under the target field; Create a target spreadsheet based on the target spreadsheet type identifier, create a file output stream to output data to the target spreadsheet, and use the file output stream to write the target data corresponding to each original data under the target field into the target spreadsheet. In response to the original data under each original field in the original database, the target data under the target field is written into the target spreadsheet, and a download link for the target spreadsheet is output.

2. The method according to claim 1, characterized in that, The step of determining the data type conversion function corresponding to each original field based on the field type of the original field and the field type of the target field corresponding to the original field includes: Obtain the mapping relationship between multiple preset types of the original field and multiple preset types of the target field and multiple preset type conversion functions; From the mapping relationship between multiple preset types of the original field and multiple preset types of the target field and multiple preset type conversion functions, determine the data type conversion function corresponding to each original field; the data type conversion function corresponding to the original field has a mapping relationship with the field type of the original field, and also has a mapping relationship with the field type of the target field corresponding to the original field.

3. The method according to claim 1, characterized in that, The step of using the data type conversion function corresponding to the original field to perform field type conversion on the original data includes: Input the original data into the data type conversion function corresponding to the original field; Use the data type conversion function corresponding to the original field of the original data to output the converted original data.

4. The method according to claim 1, characterized in that, The first data processing strategy corresponding to the target field includes: a first merging strategy for multiple original data; The first data processing strategy corresponding to the target field is used to process the transformed multiple original data to obtain the target data corresponding to the target field, including: Using the first merging strategy, multiple transformed original data are merged to obtain multiple processed original data.

5. The method according to any one of claims 1-4, characterized in that, The target export strategy also includes: a second data processing strategy for each target field when multiple target field identifiers correspond to one original field identifier; After retrieving the original data under each original field from the original database in sequence according to the first preset quantity, the process further includes: In response to the fact that multiple target field identifiers correspond to one original field identifier, the data type conversion function corresponding to the original field is used to convert the field type of the original data; The transformed original data is processed using the second data processing strategy corresponding to each target field to obtain the target data corresponding to each target field.

6. The method according to claim 5, characterized in that, The second data processing strategy includes: a first splitting strategy for the raw data; The process of using a second data processing strategy corresponding to each target field to process the transformed original data to obtain the target data corresponding to each target field includes: The original data after transformation is split using the first splitting strategy corresponding to each target field to obtain the target data corresponding to each target field.

7. A data processing method, characterized in that, include: Get the data import request triggered by the user; The data import request includes the file path of the original spreadsheet to be imported and the target import strategy selected by the user from multiple preset import strategies; The target import strategy includes: target database identifier, type identifier of the original spreadsheet, at least one original field identifier in the original spreadsheet, at least one target field identifier in the target database corresponding to each original field identifier, field type of each target field and each original field, and a third data processing strategy when one target field identifier corresponds to multiple original field identifiers; Based on the field type of the original field and the field type of the target field corresponding to the original field, determine the data type conversion function corresponding to each original field; According to the second preset quantity, retrieve the original data under each original field from the original spreadsheet in sequence; In response to the target field corresponding to an original field, the data type conversion function corresponding to the original field is used to convert the field type of the original data, and the converted original data is determined as the target data under the target field corresponding to the original data. In response to the target field corresponding to multiple original fields, the data type conversion function corresponding to each original field is used to convert the field type of each original data, and the third data processing strategy corresponding to the target field is used to process the converted multiple original data to obtain the target data corresponding to the multiple original data under the target field; Create a file output stream to output data to the target database, and use the file output stream to write the target data corresponding to each original data under the target field into the target database; In response to the fact that the original data under each original field in the original spreadsheet has been written to the target database, an import completion message is output.

8. The method according to claim 7, characterized in that, The target import strategy also includes: the number of header rows; The step of sequentially retrieving the original data under each original field from the original spreadsheet according to the second preset quantity includes: Determine the starting row number for retrieving the original data based on the number of header rows; Starting from the initial row number, retrieve the original data for each target field sequentially according to the second preset quantity.

9. The method according to claim 7 or 8, characterized in that, The target import strategy also includes: a fourth data processing strategy for each target field when multiple target field identifiers correspond to one original field identifier; After obtaining the original data under each original field from the original spreadsheet in sequence according to the second preset quantity, the process also includes: In response to the fact that multiple target field identifiers correspond to one original field identifier, the data type conversion function corresponding to the original field is used to convert the field type of the original data; The transformed original data is processed using the fourth data processing strategy corresponding to each target field to obtain the target data corresponding to each target field.

10. A data processing apparatus, characterized in that, include: The first acquisition module is used to acquire data export requests triggered by the user. The data export request includes a target export strategy selected by the user from multiple preset export strategies; The target export strategy includes an original database identifier, a target spreadsheet type identifier, at least one target field identifier in the target spreadsheet, at least one original field identifier in the original database corresponding to each target field identifier, the field types of each target field and each original field, and a first data processing strategy when one target field identifier corresponds to multiple original field identifiers; The determination module is used to determine the data type conversion function corresponding to each original field based on the field type of the original field and the field type of the target field corresponding to the original field; The second acquisition module is used to sequentially acquire the original data under each original field from the original database according to the first preset quantity; The conversion module is used to convert the field type of the original data in response to the target field corresponding to an original field, using the data type conversion function corresponding to the original field, and then determining the converted original data as the target data under the target field corresponding to the original data. The first processing module is used to respond to multiple original fields corresponding to the target field, use the data type conversion function corresponding to each original field to convert the field type of each original data, and use the first data processing strategy corresponding to the target field to process the multiple original data after conversion, so as to obtain the target data corresponding to the multiple original data under the target field; The first writing module is used to create a target spreadsheet according to the target spreadsheet type identifier, create a file output stream to output data to the target spreadsheet, and use the file output stream to write the target data corresponding to each original data under the target field into the target spreadsheet. The first output module is used to respond to the fact that the target data corresponding to the original data under each original field in the original database has been written into the target spreadsheet, and outputs the download link of the target spreadsheet.

11. A data processing apparatus, characterized in that, include: The third acquisition module is used to acquire data import requests triggered by the user. The data import request includes the file path of the original spreadsheet to be imported and the target import strategy selected by the user from multiple preset import strategies; The target import strategy includes: target database identifier, type identifier of the original spreadsheet, at least one original field identifier in the original spreadsheet, at least one target field identifier in the target database corresponding to each original field identifier, field type of each target field and each original field, and a third data processing strategy when one target field identifier corresponds to multiple original field identifiers; The determination module is used to determine the data type conversion function corresponding to each original field based on the field type of the original field and the field type of the target field corresponding to the original field; The fourth acquisition module is used to sequentially acquire the original data under each original field from the original spreadsheet according to the second preset quantity; The conversion module is used to convert the field type of the original data in response to the target field corresponding to an original field, using the data type conversion function corresponding to the original field, and then determining the converted original data as the target data under the target field corresponding to the original data. The second processing module, in response to the target field corresponding to multiple original fields, uses the data type conversion function corresponding to each original field to perform field type conversion on each original data, and uses the third data processing strategy corresponding to the target field to process the multiple original data after conversion, so as to obtain the target data corresponding to the multiple original data under the target field; The second writing module creates a file output stream to output data to the target database, and uses the file output stream to write the target data corresponding to each original data under the target field into the target database. The second output module, in response to the fact that the original data under each original field in the original spreadsheet has been written to the target database, outputs an import completion prompt message.

12. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the method as described in any one of claims 1 to 9.

13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1 to 9.

14. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method of any one of claims 1 to 9.

Citation Information

Patent Citations

  • Method and device for importing data in EXCEL file to database

    CN103020089A

  • Data synchronization method and system

    CN108133007A