Method and system for realizing efficient conversion from CSV to XML

By identifying and utilizing unique identifiers in CSV files, the verbose problem of converting nested structures into XML in CSV files is solved, and the logical structure accuracy and readability of XML data is achieved.

CN119294359AInactive Publication Date: 2025-01-10BEIJING BIDI INTELLIGENT TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411285902.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-13
Publication Date
2025-01-10
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The presence of implicit nesting structures in CSV files makes the converted XML data verbose and difficult to read, and the prior art cannot accurately display the nested relationship between data.

Method used

By obtaining the original data in the CSV file for preprocessing, unique identifiers are determined, including the primary table unique identifier and the subtable unique identifier, analyzing the data types and missing data, calculating the identifier possibilities, generating nested structure data, and It is converted into an XML file to ensure the logical structure of the XML data is accurate.

Benefits of technology

It realizes the accurate reflection of data record relationships in XML files, and improves the readability of data and subsequent processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119294359A_ABST
    Figure CN119294359A_ABST
Patent Text Reader

Abstract

The invention discloses a method and system for achieving efficient conversion from CSV to XML, and relates to the technical field of data processing. The method comprises the steps of obtaining original data based on a CSV file; preprocessing the original data to obtain corrected data; obtaining unique identification data based on the correction data; based on the unique identification data, converting the correction data into nested structure data; and obtaining the XML file based on the nested structure data. According to the method, the data possibly having the nested structure is determined by analyzing the corresponding relation of different types of data in the CSV file and the similarity of the row and column data. And then, based on the unique identification data in the nested structure, the mapping logic and the label of the XML are determined, so that accurate conversion is performed. Therefore, the relationship of different data records in the XML file can be accurately reflected, and the readability of the data and the subsequent processing efficiency are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data processing, and in particular to a method and system for realizing efficient conversion from CSV to XML. Background Art

[0002] Comma-Separated Values ​​(CSV) and Extensible Markup Language (XML) have different meanings and advantages in different application scenarios. Converting CSV to XML can enhance the data's expressiveness, interoperability, semantic information, validation capabilities, and compatibility. Although CSV is very effective in simple data records, XML provides greater flexibility and scalability in scenarios that require complex structures, data exchange standardization, and semantic enhancement.

[0003] In the process of converting data in a CSV file into data in an XML file, since the data in the CSV file is displayed flatly in the form of text, the conversion logic is generally determined by the identifier corresponding to the data and mapped sequentially when converted to an XML file. However, if the data in the CSV file has an implicit nested structure (for example, the relationship between the main table and the sub-table), the XML data logic based only on the mapping of the data identifier cannot accurately display the nested structure between different data, resulting in the converted XML data being lengthy and difficult to read. Summary of the invention

[0004] The purpose of the present application is to provide a method and system for realizing efficient conversion from CSV to XML, so as to solve the technical problem in the prior art that if the data in the CSV file has an implicit nested structure, the converted XML data will be lengthy and difficult to read.

[0005] To achieve the above objectives, this application provides the following technical solutions:

[0006] In a first aspect, the present application proposes a technical solution for realizing an efficient conversion method from CSV to XML, the method comprising:

[0007] Based on a CSV file, obtaining raw data; the CSV file is obtained in advance;

[0008] Preprocess the original data to obtain corrected data;

[0009] Based on the modified data, unique identification data is obtained; the unique identification data includes a main table unique identifier and a sub-table unique identifier;

[0010] Based on the unique identification data, the modified data is converted into nested structure data; the nested structure data at least represents the nested relationship between the various data in the original data;

[0011] Based on the nested structure data, an XML file is obtained.

[0012] As a specific solution in the technical solution of the present application, the preprocessing of the original data to obtain the corrected data includes:

[0013] Based on the original data, a first column of data is obtained; the first column of data is any column of data in the original data;

[0014] Obtain the data type of each data in the first column of data;

[0015] Based on the data type of each data, obtain the abnormal data type;

[0016] Correct the data corresponding to the abnormal data type in the first column of data to obtain a first column of corrected data;

[0017] Based on the first column of corrected data, revised data is obtained.

[0018] As a specific solution in the technical solution of the present application, the step of obtaining the corrected data based on the first column of corrected data includes:

[0019] Based on the first column of corrected data, a first row of data is obtained; the first row of data is any row of data in the original data;

[0020] Get the number of data in the first row of data;

[0021] Based on the number of data, obtaining missing data;

[0022] Correct the missing data and obtain the first row of corrected data;

[0023] Based on the first row of corrected data, revised data is obtained.

[0024] As a specific solution in the technical solution of the present application, the obtaining of unique identification data based on the correction data includes:

[0025] Based on the revised data, a second column of data is obtained; the second column of data is any column of data in the revised data;

[0026] Based on the second column of data, obtaining the first data type quantity and / or the first non-missing data quantity and / or the column ordinal number;

[0027] Based on the first data type quantity and / or the first non-missing data quantity and / or the column sequence number, obtaining the possibility of a unique identifier of the main table;

[0028] Based on the possibility of the unique identifier of the main table, obtaining a unique identifier of the main table;

[0029] Based on the master table unique identifier, unique identification data is obtained.

[0030] As a specific solution in the technical solution of the present application, the calculation formula for obtaining the possibility of the unique identifier of the main table based on the first data type number and / or the first non-missing data number and / or the column sequence number is as follows:

[0031]

[0032] Among them, γ x represents the possibility that the field corresponding to the data in the xth column of the revised data is the unique identifier of the primary table; Y represents the total number of columns in the revised data; Y x Indicates the column number corresponding to the x-th column data; H x represents the number of the first non-missing data in the x-th column; Z is the total number of rows of corrected data; G x The number of the first data type of the x-th column data.

[0033] As a specific solution in the technical solution of the present application, after obtaining the unique identification data based on the unique identifier of the main table, the method further includes:

[0034] Based on the revised data, a third column of data is obtained; the third column of data is any column of data in the revised data that is different from the second column of data;

[0035] Based on the third column of data, obtaining the second data type quantity and / or the second non-missing data quantity;

[0036] Based on the number of the second data types and / or the number of the second non-missing data, obtaining a possibility of a sub-table unique identifier;

[0037] Based on the sub-table unique identifier possibility, obtaining a sub-table unique identifier;

[0038] Based on the main table unique identifier and the sub-table unique identifier, unique identification data is acquired.

[0039] As a specific solution in the technical solution of the present application, the calculation formula for obtaining the possibility of the sub-table unique identifier based on the number of the second data type and / or the number of the second non-missing data is as follows:

[0040]

[0041] Among them, β r represents the possibility that the field corresponding to the data in the rth column of the revised data is the unique identifier of the subtable; Y0 represents the maximum number of rows with the same data type in the data in the rth column; G r is the number of the second data type of the data in the rth column; H r Indicates the number of the second non-missing data in the rth column.

[0042] As a specific solution in the technical solution of the present application, based on the nested structure data, obtaining an XML file includes:

[0043] Based on the nested structure data, a second row of data is obtained; the second row of data is any row of data in the nested structure data;

[0044] If the second row of data does not have a nested structure, directly converting the second row of data into XML file data;

[0045] If the second row of data has a nested structure, the unique identifier of the main table is used as the parent tag of the second row of data, and the identifiers corresponding to other fields are used as child tags, and then the second row of data is converted into XML file data.

[0046] As a specific solution in the technical solution of the present application, after obtaining the XML file based on the nested structure data, the method further includes:

[0047] An error report is generated by using the original data and corrected data corresponding to all abnormal data types and missing data in the nested structure data; the original data and corrected data in the error report correspond one to one.

[0048] In the second aspect, the present application proposes a technical solution for realizing an efficient conversion system from CSV to XML, and the efficient conversion system from CSV to XML comprises:

[0049] A reader, used for obtaining raw data based on a CSV file; the CSV file is obtained in advance;

[0050] A processor, used for preprocessing the original data to obtain corrected data;

[0051] And, based on the revised data, obtaining unique identification data; the unique identification data includes a main table unique identifier and a sub-table unique identifier;

[0052] And, based on the unique identification data, converting the modified data into nested structure data; the nested structure data at least represents the nested relationship between the respective data in the original data;

[0053] And, based on the nested structure data, an XML file is obtained.

[0054] As a specific solution in the technical solution of the present application, the processor is further used to obtain a first column of data based on the original data; the first column of data is any column of data in the original data;

[0055] And, obtaining the data type of each data in the first column of data;

[0056] and, based on the data type of each data, obtaining the abnormal data type;

[0057] and, correcting the data corresponding to the abnormal data type in the first column of data to obtain a first column of corrected data;

[0058] And, based on the first column of corrected data, obtaining revised data.

[0059] As a specific solution in the technical solution of the present application, the processor is further used to obtain a first row of data based on the first column of corrected data; the first row of data is any row of data in the original data;

[0060] And, obtaining the number of data in the first row of data;

[0061] and, based on the number of data, obtaining missing data;

[0062] and, correcting the missing data to obtain a first row of corrected data;

[0063] And, based on the first row of corrected data, obtaining revised data.

[0064] As a specific solution in the technical solution of the present application, the processor is further used to obtain a second column of data based on the corrected data; the second column of data is any column of data in the corrected data;

[0065] And, based on the second column of data, obtaining the first data type quantity and / or the first non-missing data number and / or the column ordinal number;

[0066] And, based on the first data type quantity and / or the first non-missing data quantity and / or the column sequence number, obtaining the possibility of a unique identifier of the main table;

[0067] and, based on the master table unique identifier possibility, obtaining a master table unique identifier;

[0068] And, based on the master table unique identifier, unique identification data is obtained.

[0069] As a specific solution in the technical solution of the present application, the processor obtains the calculation formula of the possibility of the unique identifier of the main table based on the first data type number and / or the first non-missing data number and / or the column sequence number as follows:

[0070]

[0071] Among them, γ x represents the possibility that the field corresponding to the data in the xth column of the revised data is the unique identifier of the primary table; Y represents the total number of columns in the revised data; Y x Indicates the column number corresponding to the x-th column data; H x represents the number of the first non-missing data in the x-th column; Z is the total number of rows of corrected data; G x The number of the first data type of the x-th column data.

[0072] As a specific solution in the technical solution of the present application, the processor is further used to obtain a third column of data based on the corrected data; the third column of data is any column of data in the corrected data that is different from the second column of data;

[0073] And, based on the third column of data, obtaining the second data type quantity and / or the second non-missing data quantity;

[0074] And, based on the number of the second data types and / or the number of the second non-missing data, a possibility of obtaining a sub-table unique identifier;

[0075] and, based on the sub-table unique identifier possibility, obtaining a sub-table unique identifier;

[0076] And, based on the main table unique identifier and the sub-table unique identifier, unique identification data is obtained.

[0077] As a specific solution in the technical solution of the present application, the processor obtains the calculation formula of the possibility of the sub-table unique identifier based on the number of the second data type and / or the number of the second non-missing data as follows:

[0078]

[0079] Among them, β r represents the possibility that the field corresponding to the data in the rth column of the revised data is the unique identifier of the subtable; Y0 represents the maximum number of rows with the same data type in the data in the rth column; G r is the number of the second data type of the data in the rth column; H r Indicates the number of the second non-missing data in the rth column.

[0080] As a specific solution in the technical solution of the present application, the processor is further used to obtain a second row of data based on the nested structure data; the second row of data is any row of data in the nested structure data;

[0081] And, if the second row of data does not have a nested structure, directly converting the second row of data into XML file data;

[0082] And, if the second row of data has a nested structure, the unique identifier of the main table is used as the parent tag of the second row of data, and the identifiers corresponding to other fields are used as child tags, and then the second row of data is converted into XML file data.

[0083] As a specific solution in the technical solution of the present application, the processor is also used to generate an error report for the original data and corrected data corresponding to all abnormal data type data and missing data in the nested structure data; the original data and corrected data in the error report correspond one to one.

[0084] Compared with the prior art, the beneficial effects of this application are:

[0085] This application determines the data that may have a nested structure by analyzing the corresponding relationship between different types of data in the CSV file and the similarity of row and column data. Then, the mapping logic and tags of XML are determined based on the unique identification data in the nested structure, so as to perform accurate conversion. This allows the relationship between different data records in the XML file to be accurately reflected, improving the readability of the data and the efficiency of subsequent processing. BRIEF DESCRIPTION OF THE DRAWINGS

[0086] Figure 1 A flowchart of a method for efficiently converting CSV to XML proposed in an embodiment of the present application;

[0087] Figure 2 A schematic diagram of the structure of a system for realizing efficient conversion from CSV to XML proposed in an embodiment of the present application;

[0088] Figure 3 A schematic diagram of a CSV file data proposed in an embodiment of the present application;

[0089] Figure 4 for Figure 3 Schematic diagram after the CSV file data is converted into the XML file data;

[0090] Figure 5 for Figure 4 Schematic diagram of the last row of data;

[0091] Figure 6 for Figure 4Schematic diagram of the first two rows of data. DETAILED DESCRIPTION

[0092] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0093] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0094] The terms "first", "second", etc. in the description of the embodiment of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence, such as the first column of data and the second column of data proposed below, which belong to different column data. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments described here can be implemented in an order other than the content illustrated or described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or modules is not necessarily limited to those steps or modules clearly listed, but may include other steps or modules that are not clearly listed or inherent to these processes, methods, products or devices. The division of modules that appear in the embodiment of the present application is only a logical division. There may be other division methods when implemented in actual applications, such as multiple modules can be combined or integrated into another system, or some features can be ignored, or not executed. In addition, the coupling or direct coupling or communication connection between each other shown or discussed can be through some interfaces, and the indirect coupling or communication connection between modules can be electrical or other similar forms, which are not limited in the embodiment of the present application. Furthermore, the modules or sub-modules described as separate components may or may not be physically separated, may or may not be physical modules, or may be distributed in multiple circuit modules, and some or all of the modules may be selected according to actual needs to achieve the purpose of the embodiment of the present application.

[0095] In order to solve the technical problem in the background technology that if the data in the CSV file has an implicit nested structure, the converted XML data is lengthy and difficult to read, the present application proposes an embodiment of a method for realizing efficient conversion from CSV to XML, such as Figure 1 As shown, the method includes steps S100 to S500.

[0096] Step S100: Obtaining original data based on the CSV file.

[0097] In this embodiment, the CSV file is obtained in advance, that is, there is no restriction on the source of the CSV file. For example, the CSV file can be a file downloaded from the Internet, or a CSV file created by editing. It should be noted that obtaining raw data based on CSV files is a mature technology and will not be described in detail here. Specifically, the raw data in the CSV file is as follows: Figure 3 As shown. Figure 3 As shown, this application takes the user's order data as an example to illustrate the efficient conversion method from CSV to XML proposed in this application. It does not mean that the efficient conversion method from CSV to XML proposed in this application is only applicable to the application scenario of user's order data.

[0098] In this embodiment, the user's order data is used as an example data for explanation, wherein each data record is separated by a comma. The first row of data is an identifier, wherein OrderID is the order number, OrderDate is the order date, CustomerName is the customer name, ItemID is the product number, ItemName is the product name, Quantity is the product quantity, and Price is the price.

[0099] Step S200: pre-process the original data to obtain corrected data.

[0100] It should be clear that if Figure 3 As shown, there are missing data and data of abnormal data types in the original data. Missing data refers to the lack of data corresponding to a row or a column; data of abnormal data types refers to the type of data corresponding to a column being inconsistent with the type of other data in the column. If these data are not corrected, data confusion is likely to occur during the subsequent conversion process. In an embodiment of the present application, the original data can be preprocessed in any suitable manner to obtain corrected data. For example, the missing data and data of abnormal data types in the original data are replaced by " / ".

[0101] In one embodiment of the present application, in order to accurately identify and correct abnormal data types, step S200 pre-processes the original data to obtain corrected data, including steps S210 to S250.

[0102] It should be clear that in order to facilitate Figure 3 The data in this application are observed. Figure 4 As shown, the original data of the CSV file is displayed in the form of a table. Since the data types of the same column in the CSV file may be inconsistent, for example, the Quantity and Price fields may contain non-numeric characters, which will cause errors when generating XML files or generate invalid XML files. That is to say, in this embodiment, it is first necessary to find out the abnormal data type data in the original data. For example: the Price field represents the price of the product, and the records therein should be floating point data, but if the price is free or unknown, there may be a record of non-numeric string type data such as "free", "unknown" (that is, data of abnormal data type), then these data records may cause parsing errors after conversion to XML format or require additional logic to handle these abnormal values, increasing the complexity of data processing.

[0103] Step S210: Based on the original data, obtain the first column of data.

[0104] It should be clear that the first column of data is any column of data in the original data. That is to say, in this embodiment, it is necessary to traverse all the data in the original data to find all the data of the constant data type in the original data.

[0105] Step S220: Obtain the data type of each data in the first column of data.

[0106] As can be seen from the foregoing, in the embodiments of the present application, data types include strings, integers, floating point numbers, date and time, etc. Since the data types of CSV files are mature technologies, they are not listed in detail.

[0107] Step S230: Based on the data type of each data, obtain the abnormal data type.

[0108] It should be clear that since the data types in each column of the original data are basically the same, and the data with abnormal data types only accounts for a very small part, the data type of a certain data can be compared with the data types of other data in the column. The higher the similarity, the more likely the data is to be the correct data type; otherwise, it is abnormal data type data.

[0109] In the embodiment of the present application, the similarity between each data type can be calculated in any manner. For example, the similarity between each data type can be calculated using cosine similarity or Euclidean distance. In one embodiment of the present application, step S230, based on the data type of each data, the calculation method for obtaining the abnormal data type is as follows: the data type of each data is compared by means of XOR gate logic (that is, the same 1 and different 0).

[0110] Specifically, the calculation formula is as follows:

[0111] A ij =DT i xorDT j

[0112] Among them, A ij Indicates whether the data types of the i-th data and the j-th data in the first column are the same; if they are the same, then A ij =1; if different, then A ij =0; DT i Indicates the data type of the i-th data in the first column; DT j Represents the data type of the jth data in the first column of data; xor represents the exclusive OR operator; i and j both belong to ∈[1, N], and i and j are not equal, where N is the number of data in the first column of data.

[0113] It should be clear that based on the calculation formula above, each data in the first column of data can obtain an XOR result sequence, which is {A i1 , A i2 …A iN}. Since the XOR result corresponding to the same data type is 1, the XOR result of different data types is 0, and most data records are of the correct data type, the number of 1s in the XOR result sequence corresponding to the correct data type data is relatively large. Then, by adding the data in the XOR result sequence corresponding to each data, the data type similarity of the data can be obtained. It is easy to understand that the greater the data type similarity of a data, the more likely the data type corresponding to the data is a normal data type. Of course, in the embodiments of the present application, the average value of the data in the result sequence can also be taken as the data type similarity of the data.

[0114] In an embodiment of the present application, if the data type similarity of a data is less than a first preset value, the data type corresponding to the data can be considered to be an abnormal data type. In this embodiment, the first preset value can be set according to demand. For example, if the data type similarity of the data is the average value of the data in the result sequence, the first preset value can be 0.5; if the data type similarity of the data is the addition of the data in the XOR result sequence, the first preset value can be N / 2, where N is the number of data in the first column of data.

[0115] Step S240: Correct the data corresponding to the abnormal data type in the first column of data to obtain a first column of corrected data.

[0116] It should be clear that the above steps can filter the data types in all column data in the original data, and then obtain all data of abnormal data types. Then the data of these abnormal data types can be converted to data of the same data type as other normal data types. For example, string data such as "free" and "unknown" can be converted to floating point value data such as "0.00" or "0.0". If there are some data of abnormal data types that cannot be converted, errors can be marked so that this data can be skipped when it is subsequently converted to XML format, thereby avoiding conversion exceptions.

[0117] Step S250: obtaining revised data based on the first column of corrected data.

[0118] It should be clear that in the embodiments of the present application, the original data after the correction of abnormal data type data can be used as the corrected data. It should be noted that in the original data, some data may be missing in a row, which may cause the data to be lost or skipped when the XML file is generated from the CSV file, thereby affecting the integrity of the data. For example, Figure 4 As shown in the figure, if the price data of a row is missing, this position may not appear in the generated XML file. <price>Tags. This may cause problems when parsing the XML file downstream, because the expected tags do not exist, so the missing values ​​need to be filled. That is, these missing data need to be determined from the original data. That is, in an embodiment of the present application, step S250, based on the first column of corrected data, obtains the corrected data, and may also include steps S251 to S255.

[0119] Step S251: based on the first column of corrected data, obtain the first row of data.

[0120] It should be clear that the first row of data is any row of data in the original data that has completed the first correction above. That is to say, in this embodiment, it is necessary to traverse all the data in the above data to find out whether there is data missing in each row of the original data.

[0121] Step S252: Obtain the number of data in the first row of data.

[0122] It should be clear that the number of data in each row of data is generally equal to the number of data columns in the original data. If there is missing data in a row, the number of data in this row must be less than the number of data columns in the original data. Figure 3 As shown in the figure, since each data in the CSV file is presented in the form of text + commas, if data is missing at a certain position, two consecutive commas will appear at the corresponding position. At the same time, the missing position will cause a difference in the number of data records in the corresponding row (such as Figure 4 As shown in the figure, in order to determine the missing position, it is necessary to compare the number of data records in different rows and columns. Since the number of fields in each CSV file is fixed, that is, the number of columns is fixed, the number of data in different rows can be analyzed based on the number of columns, as shown in the calculation formula:

[0123] H k =1-|C k -C0|

[0124] Among them, H k Indicates whether the kth row in the original data is missing data. If H k If H is greater than 0, it means that there is no missing data in the kth row of the original data; k If it is less than or equal to 0, it means that the kth row of the original data is missing data; C k represents the number of data in the kth row of the original data; C0 represents the number of data columns in the original data.

[0125] Step S253: Based on the number of data, obtain missing data.

[0126] It should be clear that if data is missing in a CSV file, two "," will appear at the missing data location, so the missing data can be obtained based on the location where the two "," appear. For example, Figure 3 and Figure 4 It can be seen that the Quantity data in the last row is missing.

[0127] Step S254: Correct the missing data and obtain the first row of corrected data.

[0128] It should be clear that in the embodiments of the present application, any suitable method can be used to correct missing data. For example, the missing data (i.e., where two "," appear in the original data) can be filled with a set default value or "Null", etc., and the filled places are marked for subsequent queries.

[0129] Step S255: obtaining revised data based on the first row of corrected data.

[0130] In the embodiment of the present application, the original data that has been corrected in the first column and the first row can be used as the revised data.

[0131] Step S300: Acquire unique identification data based on the correction data.

[0132] It should be clear that the unique identifier in CSV means ensuring that each row of data in the CSV file has a unique identifier value, that is, each row of data in the CSV file is unique. Figure 4 Shown and Figure 5 As shown, the last row of data can be uniquely identified by OrderID (ie, order number), so OrderID can be used as the unique identification data (ie, unique identifier) ​​of the row of data.

[0133] It should be noted that some rows of data in the CSV file may have implicit nested structures. If such nested structures are simply converted using the unique identification data generated based on a unique identifier, the redundancy of the XML structure will increase and the nested relationship of the corresponding data records cannot be displayed. Figure 6 As shown, in this embodiment Figure 4 Take the two rows of data records with OrderID 1 as an example. The OrderID in these two rows of data is 1, and their ItemID (i.e., product number) is 101 and 102 respectively, indicating that there are two products under this order, corresponding to different ItemName (i.e., product name), Quantity (i.e., product quantity) and Price (i.e., price). In other words, two products are nested under this order, so when converting to XML structure, these two products need to be nested in the tag structure of this order. If only based on OrderID, it is impossible to uniquely distinguish these two rows of data.

[0134] Since the original CSV data may contain the nested structure, in order to make the nested structure more accurately reflected in the subsequent XML file, it is necessary to traverse each row of the original CSV data and filter out the unique identification data to determine whether the row has a nested structure with other rows. From the above example, we can know that if a row of CSV data only needs one unique identifier (for example, Figure 5 The OrderID shown in the figure can uniquely identify the row of data, which means that the row of data does not have a nested structure with the data of other rows. If multiple unique identifiers are required (for example, Figure 6 The OrderID and ItemID shown in the figure can uniquely identify the data in this row, which means that the data in this row has a nested structure with the data in other rows.

[0135] In the embodiments of the present application, Figure 5 The row of data shown does not have a nested structure, but Figure 6 The two rows of data shown have a nested structure because OrderID represents the order number and ItemID represents the product number. From the perspective of the data table, they are the main table unique identifier (i.e. OrderID) and the sub-table unique identifier (i.e. ItemID). If an order number corresponds to multiple product numbers, there is a one-to-many relationship, which means there is a nested result. So for any data record in the CSV source file, if you want to filter out possible nested results, you need to determine the unique identifier data. That is, you need to determine the main table unique identifier and the sub-table unique identifier.

[0136] It should be clear that for the unique identifier of the main table, its corresponding identifier is generally close to the head of the column, and there are no missing values ​​in the column data and the corresponding abnormal data type is small. Figure 3 As shown, the main table unique identifier (i.e., OrderID) is in the first column, and there is no missing data in the first column, and there is no abnormal data type in the first column (i.e., the data types are all numerical values). Therefore, the main table unique identifier can be obtained based on this feature. Specifically, in an embodiment of the present application, step S300, based on the modified data, obtains unique identification data, including steps S310 to S350.

[0137] Step S310: Based on the corrected data, obtain a second column of data.

[0138] It should be clear that in this embodiment, the second column of data is any column of data in the revised data. That is, in this embodiment, it is necessary to determine whether the identifier corresponding to each column of data is likely to be the unique identifier of the main table.

[0139] Step S320: Based on the second column of data, obtain the first data type quantity and / or the first non-missing data quantity and / or the column ordinal number.

[0140] In this embodiment, the first data type number refers to the number of data types contained in the second column of data. For example, if a column of data only contains numerical data, the first data type number of the column of data is 1; if a column of data only contains numerical data and string data, the first data type number of the column of data is 2... and so on. In this embodiment, the first non-missing data number refers to the number of non-missing data in the second column of data. Figure 4 As shown in , if the second column data is the column data corresponding to OrderID, the number of the first non-missing data is 8; if the second column data is the column data corresponding to Quantity, the number of the first non-missing data is 7. In this embodiment, the column ordinal number refers to the sequence number of the second column data in the corrected data (or original data), such as Figure 4 As shown, if the second column data is the column data corresponding to OrderID, the column sequence number is 1; if the second column data is the column data corresponding to Quantity, the sequence number is 6.

[0141] Step S330: Based on the first data type quantity and / or the first non-missing data quantity and / or the column sequence number, obtain the possibility of the unique identifier of the main table.

[0142] As can be seen from the foregoing, if the second column of data is closer to the column head, the number of missing data is smaller, and the data type is smaller, then the possibility that the identifier corresponding to the second column of data is the unique identifier of the main table is greater. That is to say, in an embodiment of the present application, the possibility of the unique identifier of the main table can be obtained in any way based on the number of the first data type and / or the number of the first non-missing data and / or the column ordinal number. For example, in one embodiment of the present application, the possibility of the unique identifier of the main table can be the number of the first non-missing data divided by the column ordinal number.

[0143] In a specific embodiment of the present application, in step S330, based on the number of the first data types and / or the number of first non-missing data and / or the column sequence number, a calculation formula for obtaining the possibility of a unique identifier of the main table is as follows:

[0144]

[0145] Among them, γ x represents the possibility that the field corresponding to the xth column of data (i.e., the second column of data) in the revised data is the unique identifier of the primary table; Y represents the total number of columns in the revised data; Y x Indicates the column number corresponding to the x-th column data; H x represents the number of the first non-missing data in the x-th column; Z is the total number of rows of corrected data; G x is the number of the first data type of the data in the xth column. It is easy to understand that if (YY x ) is larger, the smaller the column number of the x-th column data is, that is, the x-th column data is closer to the first column; Z / G x The larger the value, the smaller the number of first data types. That is, in this embodiment, γ x The larger the value is, the more likely it is that the field corresponding to the xth column of data (that is, the second column of data) is the unique identifier of the primary table.

[0146] Step S340: Based on the possibility of the main table unique identifier, obtain the main table unique identifier.

[0147] In the embodiment of the present application, the identifier (ie, field) corresponding to the column data with the maximum probability of the unique identifier may be selected as the unique identifier of the main table.

[0148] Step S350: Based on the master table unique identifier, obtain unique identification data.

[0149] As can be seen from the foregoing, after obtaining the main table unique identifier, it is also necessary to obtain the sub-table unique identifier. In the embodiment of the present application, after obtaining the unique identification data based on the main table unique identifier in step S350, the method further includes steps S351 to S355.

[0150] Step S351: Based on the corrected data, obtain the third column of data.

[0151] It should be clear that the field (i.e., identifier) ​​corresponding to the second column of data is the unique identifier of the main table. Since the unique identifier of the sub-table must be different from the unique identifier of the main table, the third column of data in this embodiment is any column of the corrected data that is different from the second column of data.

[0152] Step S352: Based on the third column of data, obtain the second data type quantity and / or the second non-missing data quantity.

[0153] It should be noted that, in this embodiment, the sub-table unique identifier is similar to the primary key and meets the main characteristics of the primary key, that is, the data in the third column have less duplication and less missing data.

[0154] It should be noted that the second number of data types refers to the number of data types contained in the third column of data. For example, if a column of data (that is, the third column of data) contains only numerical data, the first number of data types in the column of data is 1; if a column of data contains only numerical data and string data, the first number of data types in the column of data is 2, and so on. The second number of non-missing data refers to the number of non-missing data in the third column of data. Figure 4 As shown, if the third column data is the column data corresponding to OrderID, the number of the second non-missing data is 8; if the third column data is the column data corresponding to Quantity, the number of the second non-missing data is 7.

[0155] Step S353: Based on the number of the second data types and / or the number of the second non-missing data, obtain the possibility of the sub-table unique identifier.

[0156] It should be clear that in the embodiments of the present application, the possibility of the sub-table unique identifier can be obtained in any manner based on the number of the second data types and / or the number of the second non-missing data. For example, in one embodiment of the present application, the calculation formula for the possibility of the sub-table unique identifier can be as follows:

[0157]

[0158] Among them, β r Indicates the possibility that the field corresponding to the rth column of data (that is, the third column of data) in the revised data is the unique identifier of the subtable; G r is the number of the second data type of the data in the rth column; H r Indicates the number of the second non-missing data in the rth column.

[0159] In another embodiment of the present application, in step S353, based on the number of the second data types and / or the number of the second non-missing data, a calculation formula for obtaining the possibility of the sub-table unique identifier is as follows:

[0160]

[0161] Where, β. represents the possibility that the field corresponding to the data in the rth column (that is, the third column) in the revised data is the unique identifier of the subtable; Y0 represents the maximum number of rows with the same data type and different data in the rth column; G r is the number of the second data type of the data in the rth column; H r represents the number of the second non-missing data in the rth column. r Represents the data repetition rate of the data in the rth column. The larger its value is, the greater the difference between the data of the same data type in the rth column is, indicating that the data repetition rate of the column is lower. r The second is the number of non-missing data. The larger its value is, the less missing data in this column is.

[0162] Step S354: Based on the sub-table unique identifier possibility, obtain the sub-table unique identifier.

[0163] In the embodiment of the present application, the identifier (ie, field) of the third column of data corresponding to the maximum sub-table unique identifier possibility may be used as the sub-table unique identifier.

[0164] Step S355: Based on the main table unique identifier and the sub-table unique identifier, obtain unique identification data.

[0165] It should be clear that the unique identification data formed based on the main table unique identifier and the sub-table unique identifier can uniquely determine the data of each row in the revised data. It should be noted that in this embodiment, the main table unique identifier is unique, but the sub-table unique identifier may not be "unique", for example: if multiple fields (i.e., identifiers) meet the conditions of the sub-table unique identifier, for example: Figure 3 As shown in the embodiment, the combination of OrderID+ItemID can determine a unique product, and OrderID+ItemName can also determine a unique product, so they can be flexibly matched in this embodiment.

[0166] Step S400: Based on the unique identification data, convert the revised data into nested structure data.

[0167] It should be clear that the nested structure data at least represents the nested relationship between the various data in the original data. As can be seen from the foregoing, in the embodiment of the present application, the nested relationship between the various data in the revised data can be reflected by the main table unique identifier and the sub-table unique identifier in the unique identification data. For example, if a row of data only has the main table unique identifier, it means that the row of data has no nested relationship with other data; if a row of data has a corresponding sub-table unique identifier, then the row of data has a nested relationship with other data.

[0168] Step S500: Based on the nested structure data, an XML file is obtained.

[0169] It should be clear that in an embodiment of the present application, an XML file can be obtained based on the nested structure data based on the conversion method of the prior art. In order to accurately convert the CSV file into an XML file, in an embodiment of the present application, step S500, based on the nested structure data, obtains the XML file, including steps S510 to S530.

[0170] Step S510: Based on the nested structure data, obtain the second row of data.

[0171] It should be clear that in the embodiment of the present application, each row of data in the nested structure data is converted row by row. That is, the second row of data is any row of data in the nested structure data.

[0172] Step S520: If the second row of data does not have a nested structure, the second row of data is directly converted into XML file data.

[0173] Specifically, Figure 3 Take the last row of data in as an example. Since this row of data does not have a nested structure, the procedure for converting this row of data into XML file data is as follows:

[0174] <order>

[0175] <orderid> 4< / orderid>

[0176] <orderdate> 2024-08-30< / orderdate>

[0177] <customername> Jane Smith< / customername>

[0178] <itemid> 401< / itemid>

[0179] <itemname> WidgetH< / itemname>

[0180] <quantity> Null< / quantity>

[0181] <price> 7.00< / price>

[0182] < / order>

[0183] Step S530: If the second row of data has a nested structure, the unique identifier of the main table is used as the parent tag of the second row of data, and the identifiers corresponding to other fields are used as child tags, and then the second row of data is converted into XML file data.

[0184] Specifically, Figure 3 Take the first two rows of data in the example. Since these two rows of data have a nested structure, then the corresponding XML tags and mapping logic are established based on the unique identifier of the main table and the unique identifier of the sub-table. Here, OrderID (that is, the unique identifier of the main table) + ItemID (that is, the unique identifier of the sub-table) is taken as an example. OrderID is the unique identifier of the main table, and each order has an OrderID. ItemID is the unique identifier of the sub-table and belongs to a certain OrderID. Take each order as a <order>element, with each line item as <orderitem>Elements are nested within corresponding <order>Element. Traverse the CSV file, group by OrderID, and convert the records with the same OrderID into a <order>element, which contains the corresponding <orderitem>element. Then Figure 3 The procedure to convert the first two rows of CSV data into XML data is as follows:

[0185] <order>

[0186] <orderid> 1< / orderid>

[0187] <orderdate> 2024-08-25< / orderdate>

[0188] <customername> JohnDoe< / customername>

[0189] <orderitems>

[0190] <orderitem>

[0191] <itemid> 101< / itemid>

[0192] <itemname> WidgetA< / itemname>

[0193] <quantity> 2< / quantity>

[0194] <price> 19.99< / price>

[0195] < / orderitem>

[0196] <orderitem>

[0197] <itemid> 102< / itemid>

[0198] <itemname> WidgetB< / itemname>

[0199] <quantity> 1< / quantity>

[0200] <price> 29.99< / price>

[0201] < / orderitem>

[0202] < / orderitems>

[0203] < / order>

[0204] After obtaining the XML file based on the nested structure data in step S500, the method further includes step S600.

[0205] Step S600: Generate an error report based on the original data and corrected data corresponding to all abnormal data types and missing data in the nested structure data; the original data and corrected data in the error report correspond one to one.

[0206] It should be clear that the purpose of this step is that some records may still be converted abnormally during the conversion process, so the conversion abnormalities are marked and an error report is generated and fed back to the relevant personnel. The relevant personnel can use the error report to know where the data has been corrected or the conversion is abnormal.

[0207] It should be clear that the efficient conversion method from CSV to XML proposed in this application determines the data that may have a nested structure by analyzing the corresponding relationship between different types of data in the CSV file and the similarity between row and column data. Then, the mapping logic and tags of XML are determined based on the unique identification data in the nested structure, so as to perform accurate conversion. This allows the relationship between different data records in the XML file to be accurately reflected, improving the readability of the data and the efficiency of subsequent processing.

[0208] After introducing an embodiment of a method for realizing efficient conversion from CSV to XML proposed in this application, the following introduces an efficient conversion system for realizing efficient conversion from CSV to XML proposed in this application. Figure 2 As shown, the efficient conversion system 10 for implementing CSV to XML includes:

[0209] A reader 11 is used to obtain raw data based on a CSV file; the CSV file is obtained in advance;

[0210] The processor 12 is used to pre-process the original data to obtain the corrected data;

[0211] And, based on the revised data, obtaining unique identification data; the unique identification data includes a main table unique identifier and a sub-table unique identifier;

[0212] And, based on the unique identification data, converting the modified data into nested structure data; the nested structure data at least represents the nested relationship between the respective data in the original data;

[0213] And, based on the nested structure data, an XML file is obtained.

[0214] As a specific embodiment of the present application, the processor 12 is further used to obtain a first column of data based on the original data; the first column of data is any column of data in the original data;

[0215] And, obtaining the data type of each data in the first column of data;

[0216] and, based on the data type of each data, obtaining the abnormal data type;

[0217] and, correcting the data corresponding to the abnormal data type in the first column of data to obtain a first column of corrected data;

[0218] And, based on the first column of corrected data, obtaining revised data.

[0219] As a specific embodiment of the present application, the processor 12 is further configured to obtain a first row of data based on the first column of corrected data; the first row of data is any row of data in the original data;

[0220] And, obtaining the number of data in the first row of data;

[0221] and, based on the number of data, obtaining missing data;

[0222] and, correcting the missing data to obtain a first row of corrected data;

[0223] And, based on the first row of corrected data, obtaining revised data.

[0224] As a specific embodiment of the present application, the processor 12 is further configured to obtain a second column of data based on the corrected data; the second column of data is any column of data in the corrected data;

[0225] And, based on the second column of data, obtaining the first data type quantity and / or the first non-missing data number and / or the column ordinal number;

[0226] And, based on the first data type quantity and / or the first non-missing data quantity and / or the column sequence number, obtaining the possibility of a unique identifier of the main table;

[0227] and, based on the master table unique identifier possibility, obtaining a master table unique identifier;

[0228] And, based on the master table unique identifier, unique identification data is obtained.

[0229] As a specific embodiment of the present application, the processor 12 obtains the possibility of the unique identifier of the main table based on the first data type number and / or the first non-missing data number and / or the column sequence number, and the calculation formula is as follows:

[0230]

[0231] Among them, γ x represents the possibility that the field corresponding to the data in the xth column of the revised data is the unique identifier of the primary table; Y represents the total number of columns in the revised data; Y x Indicates the column number corresponding to the x-th column data; H x represents the number of the first non-missing data in the x-th column; Z is the total number of rows of corrected data; G x The number of the first data type of the x-th column data.

[0232] As a specific embodiment of the present application, the processor 12 is further configured to obtain a third column of data based on the revised data; the third column of data is data in any column of the revised data that is different from the second column of data;

[0233] And, based on the third column of data, obtaining the second data type quantity and / or the second non-missing data quantity;

[0234] And, based on the number of the second data types and / or the number of the second non-missing data, a possibility of obtaining a sub-table unique identifier;

[0235] and, based on the sub-table unique identifier possibility, obtaining a sub-table unique identifier;

[0236] And, based on the main table unique identifier and the sub-table unique identifier, unique identification data is obtained.

[0237] As a specific embodiment of the present application, the processor 12 obtains the possibility of the sub-table unique identifier based on the number of the second data types and / or the number of the second non-missing data using the following calculation formula:

[0238]

[0239] Among them, β r represents the possibility that the field corresponding to the data in the rth column of the revised data is the unique identifier of the subtable; Y0 represents the maximum number of rows with the same data type in the data in the rth column; G r is the number of the second data type of the data in the rth column; H r Indicates the number of the second non-missing data in the rth column.

[0240] As a specific embodiment of the present application, the processor 12 is further configured to obtain a second row of data based on the nested structure data; the second row of data is any row of data in the nested structure data;

[0241] And, if the second row of data does not have a nested structure, directly converting the second row of data into XML file data;

[0242] And, if the second row of data has a nested structure, the unique identifier of the main table is used as the parent tag of the second row of data, and the identifiers corresponding to other fields are used as child tags, and then the second row of data is converted into XML file data.

[0243] As a specific embodiment of the present application, the processor 12 is also used to generate an error report for the original data and corrected data corresponding to all abnormal data type data and missing data in the nested structure data; the original data and corrected data in the error report correspond one to one.

[0244] It should be clear that the efficient conversion system from CSV to XML proposed in this application determines the data that may have a nested structure by analyzing the corresponding relationship between different types of data in the CSV file and the similarity of row and column data. Then, the mapping logic and tags of XML are determined based on the unique identification data in the nested structure, so as to perform accurate conversion. This allows the relationship between different data records in the XML file to be accurately reflected, improving the readability of the data and the efficiency of subsequent processing.

[0245] After introducing a system for realizing efficient conversion from CSV to XML proposed in an embodiment of the present application, an embodiment of a computer-readable storage medium proposed in the present application is introduced below. A computer program is stored on the computer-readable storage medium. When the computer program is executed by a processor, an efficient method for converting CSV to XML as described in any one of the above is implemented.

[0246] It should be clear that the computer-readable storage media in this application include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, modules of programs or other data. Examples of computer storage media include, but are not limited to, phase change memory, static random access memory, dynamic random access memory, other types of random access memory, read-only memory, electrically erasable programmable read-only memory, flash memory or other memory technology, read-only compact disc read-only memory, digital versatile disc or other optical storage, magnetic cassettes, disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include temporary computer-readable media, such as modulated data signals and carrier waves.

[0247] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0248] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the methods, devices and equipment described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0249] In the several embodiments provided in the embodiments of the present application, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.

[0250] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0251] In addition, each functional module in each embodiment of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above-mentioned integrated module can be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium.

[0252] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.

[0253] The computer program product includes one or more computer instructions. When the computer program is loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a server, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means to another website site, computer, server, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or a data center that includes one or more available media integrated. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a digital video disk), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.

[0254] Although the embodiments of the present application have been shown and described, it will be appreciated by those skilled in the art that many changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles of the present application.< / orderitem> < / order> < / order> < / orderitem> < / order> < / price>

Claims

1. A method for efficiently converting CSV to XML, characterized in that: The method comprises: Based on a CSV file, obtaining raw data; the CSV file is obtained in advance; Preprocess the original data to obtain corrected data; Based on the modified data, unique identification data is obtained; the unique identification data includes a main table unique identifier and a sub-table unique identifier; Based on the unique identification data, the modified data is converted into nested structure data; the nested structure data at least represents the nested relationship between the various data in the original data; Based on the nested structure data, an XML file is obtained.

2. The method for realizing efficient conversion from CSV to XML according to claim 1, characterized in that: The preprocessing of the original data to obtain the corrected data includes: Based on the original data, a first column of data is obtained; the first column of data is any column of data in the original data; Obtain the data type of each data in the first column of data; Based on the data type of each data, obtain the abnormal data type; Correct the data corresponding to the abnormal data type in the first column of data to obtain a first column of corrected data; Based on the first column of corrected data, revised data is obtained.

3. The method for realizing efficient conversion from CSV to XML according to claim 2, characterized in that: The obtaining of the corrected data based on the first column of corrected data includes: Based on the first column of corrected data, a first row of data is obtained; the first row of data is any row of data in the original data; Get the number of data in the first row of data; Based on the number of data, obtaining missing data; Correct the missing data and obtain the first row of corrected data; Based on the first row of corrected data, revised data is obtained.

4. The method for realizing efficient conversion from CSV to XML according to any one of claims 1 to 3, characterized in that: The obtaining of unique identification data based on the correction data includes: Based on the revised data, a second column of data is obtained; the second column of data is any column of data in the revised data; Based on the second column of data, obtaining the first data type quantity and / or the first non-missing data quantity and / or the column ordinal number; Based on the first data type quantity and / or the first non-missing data quantity and / or the column sequence number, obtaining the possibility of a unique identifier of the main table; Based on the possibility of the unique identifier of the main table, obtain the unique identifier of the main table; Based on the master table unique identifier, unique identification data is obtained.

5. The method for realizing efficient conversion from CSV to XML according to claim 4, characterized in that: The calculation formula for obtaining the possibility of the unique identifier of the main table based on the first data type number and / or the first non-missing data number and / or the column sequence number is as follows: Among them, γ x represents the possibility that the field corresponding to the data in the xth column of the revised data is the unique identifier of the primary table; Y represents the total number of columns in the revised data; Y x Indicates the column number corresponding to the x-th column data; H x represents the number of the first non-missing data in the x-th column; Z is the total number of rows of corrected data; G x The number of the first data type of the x-th column data.

6. The method for realizing efficient conversion from CSV to XML according to claim 4, characterized in that: After obtaining the unique identification data based on the master table unique identifier, the method further includes: Based on the revised data, a third column of data is obtained; the third column of data is any column of data in the revised data that is different from the second column of data; Based on the third column of data, obtaining the second data type quantity and / or the second non-missing data quantity; Based on the number of the second data types and / or the number of the second non-missing data, obtaining a possibility of a sub-table unique identifier; Based on the sub-table unique identifier possibility, obtaining a sub-table unique identifier; Based on the main table unique identifier and the sub-table unique identifier, unique identification data is acquired.

7. The method for realizing efficient conversion from CSV to XML according to claim 6, characterized in that: The calculation formula for obtaining the possibility of the sub-table unique identifier based on the second data type number and / or the second non-missing data number is as follows: Among them, β r represents the possibility that the field corresponding to the data in the rth column of the revised data is the unique identifier of the subtable; Y0 represents the maximum number of rows with the same data type in the data in the rth column; G r is the number of the second data type of the data in the rth column; H r Indicates the number of the second non-missing data in the rth column.

8. The method for realizing efficient conversion from CSV to XML according to any one of claims 1 to 3, characterized in that: Based on the nested structure data, an XML file is obtained, including: Based on the nested structure data, a second row of data is obtained; the second row of data is any row of data in the nested structure data; If the second row of data does not have a nested structure, directly converting the second row of data into XML file data; If the second row of data has a nested structure, the unique identifier of the main table is used as the parent tag of the second row of data, and the identifiers corresponding to other fields are used as child tags, and then the second row of data is converted into XML file data.

9. The method for realizing efficient conversion from CSV to XML according to claim 3, characterized in that: After obtaining the XML file based on the nested structure data, the method further includes: An error report is generated by using the original data and corrected data corresponding to all abnormal data types and missing data in the nested structure data; the original data and corrected data in the error report correspond one to one.

10. A system for efficiently converting CSV to XML, characterized in that: include: Reader, used to obtain raw data based on CSV files; The CSV file is obtained in advance; A processor, used for preprocessing the original data to obtain corrected data; and, based on the correction data, obtaining unique identification data; The unique identification data includes a main table unique identifier and a sub-table unique identifier; and, based on the unique identification data, converting the revised data into nested structure data; The nested structure data at least represents the nested relationship between each data in the original data; And, based on the nested structure data, an XML file is obtained.

Citation Information

Patent Citations

  • Test case file conversion method and device, electronic device and storage medium

    CN110597708A

  • Data format conversion method, data format conversion device, storage medium and electronic equipment

    CN111128402A

  • Statistical analysis method and system based on multi-omics and clinical data and storage medium

    CN111913999A

  • Unmanned aerial vehicle control file conversion method and device, equipment and storage medium

    CN114564919A

  • Method for restoring XML file configuration

    JP2013015935A