Data import method, device, equipment, storage medium and product

CN115617888BActive Publication Date: 2026-07-07CHINA CONSTRUCTION BANK +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA CONSTRUCTION BANK
Filing Date
2022-09-26
Publication Date
2026-07-07

AI Technical Summary

Technical Problem

Existing technologies make it difficult to quickly and intuitively view and store the relationships between different tables when importing data containing hierarchical relationships, resulting in low efficiency and a high risk of errors when manually entering data.

Method used

The data table to be imported is structured into a tree structure. The data is stored row by row in the tree data model through the form of a starting point, multiple intermediate nodes and an ending point. The tree data model is then converted into a database table. The order of the intermediate nodes is used to represent the data relationship, without the need to additionally identify the row records and parent-child relationships.

Benefits of technology

It achieves high efficiency and accuracy in data import, reduces the error rate, and can intuitively show the data relationships, thus improving the efficiency and accuracy of data import.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115617888B_ABST
    Figure CN115617888B_ABST
Patent Text Reader

Abstract

The application discloses a data import method and device, equipment, a storage medium and a product. The application relates to the technical field of computers. The method comprises the following steps: obtaining a to-be-imported data table, wherein a table header structure of the to-be-imported data table comprises a starting point, at least two intermediate nodes and an end point in sequence; storing to-be-imported data in the to-be-imported data table into a preset data model of a tree structure row by row in the direction from the starting point to the end point to obtain an imported data tree; for each two adjacent intermediate nodes in the table header structure, the intermediate node close to the starting point corresponds to a parent node in the imported data tree, and the intermediate node far from the starting point corresponds to a child node in the imported data tree; and converting the imported data tree into a database table in a preset database to realize persistent storage of the to-be-imported data, wherein different levels of tree nodes in the imported data tree correspond to different database tables. Through the technical scheme, the efficiency and accuracy of data import can be ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of computer technology, and in particular to data import methods, apparatus, devices, storage media and products. Background Technology

[0002] With the advancement of information technology, the demand for data import is constantly increasing. Data import is mostly implemented using front-end technology, utilizing a graphical interface to update and enter data, obtain the file to be imported, and then import the file into a database for persistent storage.

[0003] Currently, data import is usually implemented in the form of row records. For data import scenarios involving hierarchical relationships, which involve the relationship between different tables, a column in the parent table needs to be used as a unique identifier to identify the row record, and a column in the child table is used to store the identifier representing the parent-child relationship. When faced with a large amount of data, it is difficult to quickly and intuitively view the above relationships, making manual entry inefficient and prone to errors. Summary of the Invention

[0004] This invention provides a data import method, apparatus, device, storage medium, and product that can improve the accuracy of data import.

[0005] In a first aspect, embodiments of the present invention provide a data import method, including:

[0006] Obtain the data table to be imported, wherein the header structure of the data table to be imported includes a starting point, at least two intermediate nodes, and an ending point in sequence, and the single row of data to be imported stored in each intermediate node corresponds to at least one data in the database table;

[0007] The data to be imported from the data table to be imported is stored row by row in a tree structure preset data model in the direction from the starting point to the ending point to obtain the import data tree. For each pair of adjacent intermediate nodes in the header structure, the intermediate node closer to the starting point corresponds to the parent node in the import data tree, and the intermediate node farther from the starting point corresponds to the child node in the import data tree.

[0008] The imported data tree is converted into a database table in a preset database to achieve persistent storage of the imported data. Different levels of tree nodes in the imported data tree correspond to different database tables, and the relationship between different database tables is determined according to the hierarchical relationship of the imported data tree.

[0009] Secondly, embodiments of the present invention also provide a data import device, the device comprising:

[0010] The data table acquisition module is used to acquire the data table to be imported. The header structure of the data table to be imported includes a starting point, at least two intermediate nodes, and an ending point. Each intermediate node stores a single row of data to be imported, which corresponds to at least one data in the database table.

[0011] The data storage module is used to store the data to be imported from the data table to be imported, row by row, in the direction from the starting point to the ending point into a preset data model of a tree structure to obtain an import data tree. In this model, for each pair of adjacent intermediate nodes in the header structure, the intermediate node closer to the starting point corresponds to the parent node in the import data tree, and the intermediate node farther from the starting point corresponds to the child node in the import data tree.

[0012] The data tree conversion module is used to convert the imported data tree into database tables in a preset database to achieve persistent storage of the data to be imported. The different levels of tree nodes in the imported data tree correspond to different database tables, and the relationship between different database tables is determined according to the hierarchical relationship of the imported data tree.

[0013] Thirdly, embodiments of the present invention also provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the data import method as described in any of the embodiments of the present invention.

[0014] Fourthly, embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the data import method as described in any of the embodiments of the present invention.

[0015] Fifthly, embodiments of the present invention also provide a computer program product, including a computer program that, when executed by a processor, implements the data import method as described in any of the embodiments of the present invention.

[0016] The data import scheme provided in this embodiment of the invention obtains a data table to be imported. The header structure of the data table to be imported includes a starting point, at least two intermediate nodes, and an ending point. Each intermediate node stores a single row of data to be imported, which corresponds to at least one data record in a database table. The data to be imported in the data table is stored row by row in a tree-structured preset data model from the starting point to the ending point to obtain an import data tree. For each pair of adjacent intermediate nodes in the header structure, the intermediate node closer to the starting point corresponds to the parent node in the import data tree, and the intermediate node farther from the starting point corresponds to the child node in the import data tree. The import data tree is converted into a database table in a preset database to achieve persistent storage of the data to be imported. Different levels of tree nodes in the import data tree correspond to different database tables, and the relationship between different database tables is determined according to the hierarchical relationship of the import data tree. By adopting the above technical solution, the data to be imported that has a relationship is stored in the intermediate nodes of a unified data table to be imported. The relationship between the data to be imported stored in each intermediate node is reflected by the order of the intermediate nodes in the header structure of the data table to be imported. There is no need to use additional columns to identify row records and store identifiers representing parent-child relationships. This can more intuitively reflect the data relationship and reduce errors. When importing data, the data to be imported in the data table is first stored row by row into the import data tree, and then the import data tree is converted into a database table. This can achieve persistent storage of the data to be imported, ensuring the efficiency and accuracy of data import. Attached Figure Description

[0017] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0018] Figure 1 A flowchart of a data import method provided in an embodiment of the present invention;

[0019] Figure 2 A flowchart of another data import method provided in an embodiment of the present invention;

[0020] Figure 3 This is a schematic diagram of an imported data tree structure provided in an embodiment of the present invention;

[0021] Figure 4 This is a schematic diagram of the structure of a data import device provided in an embodiment of the present invention;

[0022] Figure 5This is a schematic diagram of the structure of an electronic device that implements the data import method of this invention. Detailed Implementation

[0023] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, the accompanying drawings show only the parts relevant to the present invention, and not all of the structures.

[0024] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this invention, terms such as "first," "second," etc., are used only for distinguishing descriptions and should not be construed as indicating or implying relative importance. The acquisition, storage, use, and processing of data in the technical solutions of this application all comply with the relevant provisions of national laws and regulations.

[0025] Figure 1 This is a flowchart of a data import method provided in an embodiment of the present invention. This embodiment is applicable to the situation of importing data into a database. The method can be executed by a data import device, which can be implemented in the form of software and / or hardware. Optionally, it can be implemented by an electronic device, such as a personal computer (PC) or a server.

[0026] like Figure 1 As shown, the method includes:

[0027] Step 101: Obtain the data table to be imported. The header structure of the data table to be imported includes a starting point, at least two intermediate nodes, and an ending point. Each intermediate node stores a single row of data to be imported, which corresponds to at least one data record in the database table.

[0028] For example, the data table to be imported can be understood as a table file containing the data to be imported; the specific format is not limited, for example, it can be in Excel format. Optionally, a template table to be imported can be predefined, and the data to be imported can be filled into the template table through data interaction between systems or manually, thus obtaining the data table to be imported.

[0029] In related technologies, for data import scenarios involving hierarchical relationships, the relationships between different tables to be imported are involved. Each table to be imported corresponds to a database table in the database. A column in the parent table needs to be used as a unique identifier to identify the row record, and a column in the child table is used to store the identifier representing the parent-child relationship. That is, the hierarchical relationship is represented in the form of a technical relationship field. Business personnel find it difficult to intuitively view the relationships between different tables to be imported, and it is easy to make mistakes.

[0030] In this embodiment of the invention, the aforementioned relationships are represented by a tree structure. This tree structure includes non-leaf nodes and leaf nodes, where a leaf node represents the end of a link, and non-leaf nodes include a root node and regular nodes, with the root node representing the start of a link. To match the tree structure, the header structure of the data table to be imported can include a start point, at least two intermediate nodes, and an end point. The start point serves as a start identifier, and the end point as an end identifier. Each intermediate node can correspond to a database table; that is, a single row of data to be imported stored in each intermediate node corresponds to at least one record in the database table. The hierarchy of the intermediate nodes decreases sequentially from the start point to the end point. For example, if the header structure includes a start point, intermediate node one, intermediate node two, intermediate node three, and the end point, then the hierarchical levels of intermediate node one, intermediate node two, and intermediate node three decrease sequentially. This can also be understood as intermediate node two depending on intermediate node one, and intermediate node three depending on intermediate node two.

[0031] To facilitate understanding, let's take a specific application scenario as an example. The data to be imported includes data from the cost allocation task, starting from the cost pool and ending at the account. Intermediate nodes can include allocation data from the cost pool to each first-level department, from each first-level department to each second-level department, and from each second-level department to each third-level department, ultimately allocating to specific accounts. In related technologies, the allocation data from the cost pool to each first-level department forms one table to be imported, the allocation data from each first-level department to each second-level department forms another table, and the allocation data from each second-level department to each third-level department forms yet another table, totaling three tables. Each table needs a dedicated column to identify row records and a dedicated column to store the parent-child relationship (technical relationship field) between the tables to be imported. In this application, the above three tables are integrated into a single table to be imported as intermediate nodes, eliminating the technical relationship field, making the table to be imported more intuitive and less prone to errors.

[0032] Step 102: Store the data to be imported from the data table row by row in the direction from the start point to the end point into the preset data model of the tree structure to obtain the import data tree. For each pair of adjacent intermediate nodes in the header structure, the intermediate node closer to the start point corresponds to the parent node in the import data tree, and the intermediate node farther from the start point corresponds to the child node in the import data tree.

[0033] For example, a preset data model of a tree structure corresponding to the header structure can be constructed. In each pair of adjacent intermediate nodes in the header structure, the intermediate node closer to the starting point corresponds to the parent node in the preset data model of the tree structure, and the intermediate node farther from the starting point corresponds to the child node in the preset data model of the tree structure. The starting point corresponds to the root node, and the ending point is used to identify the end of the link. That is, the intermediate node adjacent to the ending point in the header structure is the leaf node in the preset data model of the tree structure.

[0034] For example, the data to be imported from the data table is stored row by row in a tree-structured preset data model from the start point to the end point, resulting in an import data tree. Specifically, in each pair of adjacent intermediate nodes in the header structure, the row of data to be imported stored in the intermediate node closer to the start point is stored as the parent node in the import data tree, while the row of data to be imported stored in the intermediate node farther from the start point is stored as the child node in the import data tree. The parent and child nodes are two relative tree nodes; the same tree node can be the parent node of another tree node or a child node of another tree node.

[0035] For example, if a single row of data to be imported stored in a certain intermediate node (denoted as the first intermediate node) is related to multiple rows of data to be imported stored in the next intermediate node (denoted as the second intermediate node), then when the first intermediate node corresponds to the parent node in the imported data tree, there are multiple child nodes, and each child node stores a single row of data to be imported from the second intermediate node.

[0036] Step 103: Convert the imported data tree into database tables in a preset database to achieve persistent storage of the imported data. Different levels of tree nodes in the imported data tree correspond to different database tables, and the relationship between different database tables is determined according to the hierarchical relationship of the imported data tree.

[0037] For example, the data stored in the tree nodes of each level of the imported data tree is written into the corresponding database tables, and the relationship between different database tables is determined according to the hierarchical relationship of the imported data tree, so as to achieve persistent storage of the imported data in the database tables.

[0038] The data import scheme provided in this embodiment of the invention obtains a data table to be imported. The header structure of the data table to be imported includes a starting point, at least two intermediate nodes, and an ending point. Each intermediate node stores a single row of data to be imported, which corresponds to at least one data record in a database table. The data to be imported in the data table is stored row by row in a tree-structured preset data model from the starting point to the ending point to obtain an import data tree. For each pair of adjacent intermediate nodes in the header structure, the intermediate node closer to the starting point corresponds to the parent node in the import data tree, and the intermediate node farther from the starting point corresponds to the child node in the import data tree. The import data tree is converted into a database table in a preset database to achieve persistent storage of the data to be imported. Different levels of tree nodes in the import data tree correspond to different database tables, and the relationship between different database tables is determined according to the hierarchical relationship of the import data tree. By adopting the above technical solution, the data to be imported that has a relationship is stored in the intermediate nodes of a unified data table to be imported. The relationship between the data to be imported stored in each intermediate node is reflected by the order of the intermediate nodes in the header structure of the data table to be imported. There is no need to use additional columns to identify row records or store identifiers to represent parent-child relationships. This can more intuitively reflect the data relationship and reduce errors. When importing data, the data to be imported in the data table is first stored row by row into the import data tree, and then the import data tree is converted into a database table. This can achieve persistent storage of the data to be imported, ensuring the efficiency and accuracy of data import.

[0039] In some embodiments, the intermediate node includes multiple attribute fields, and these attribute fields and table fields in the database table have a preset mapping relationship. The step of converting the imported data tree into a database table in the preset database includes: converting the imported data tree into a database table in the preset database according to the preset mapping relationship. The advantage of this setup is that, utilizing the preset mapping relationship, the conversion from the imported data tree to a database table can be performed more quickly and accurately.

[0040] For example, attribute fields can be understood as fields with pre-defined attributes, which can be defined according to the actual application scenario. Continuing with the cost allocation task scenario as an example, attribute fields may include source filters, weights, node descriptions, scenarios, and allocation targets, etc. The allocation targets may also include factors, allocation dimensions, and factor filters, etc.

[0041] In some embodiments, the preset mapping relationship includes a one-to-one mapping relationship or a one-to-many mapping relationship; wherein, for the case where the preset mapping relationship is a one-to-many mapping relationship: if the table structure of the database table is a narrow table, then one piece of data to be imported under one attribute field corresponds to multiple pieces of data under the same table field in the database table; if the table structure of the database table is a wide table, then one attribute field corresponds to multiple table fields in the database table. The advantage of this setting is that the preset mapping relationship can be set reasonably.

[0042] For example, a one-to-one mapping relationship can be understood as an intermediate node's data being stored in only one field, that is, one attribute field corresponds to one table field; a one-to-many mapping relationship can be understood as an intermediate node having multiple corresponding attributes, or an intermediate node's data being stored in multiple rows of records in a database table.

[0043] For example, suppose the specific data content of cell A is a dimension filter condition. This filter condition can have multiple cases, such as dimension A = dimension value A & dimension B = dimension value B. If designed with a narrow table structure, this would result in two data records stored in different rows of the same table. If stored in a wide table format, the data would be stored in different fields within the same table.

[0044] In some embodiments, the number of attribute fields and the attribute definitions are the same in each of the at least two intermediate nodes. This arrangement facilitates the merging and storage of multiple database tables. For example, there may be three intermediate nodes, each containing attribute A, attribute B, and attribute C.

[0045] In some embodiments, obtaining the data table to be imported includes: determining the template table to be imported; obtaining the data to be imported; and filling the corresponding cells in the template table with the data to be imported, according to the header structure and attribute field definitions in the template table, to obtain the data table to be imported. The advantage of this approach is that by setting the template table, the header structure and attribute fields can be pre-defined, standardizing the format of the data to be imported, thereby quickly generating the data table to be imported based on the data to be imported.

[0046] For example, the data to be imported can be obtained from a system that interacts with the current electronic device. The system corresponding to each intermediate node in the header structure can be determined, and the data content can be obtained according to the correspondence between the data name and the attribute definition of the attribute field in the system. The obtained data content is then filled into the corresponding cell in the template table to be imported.

[0047] In some embodiments, storing the data to be imported from the data table to be imported, row by row, in the direction from the starting point to the ending point, into a preset data model with a tree structure to obtain an import data tree includes: validating the header structure and attribute definitions of the attribute fields of the data table to be imported; if the validation passes, storing the data to be imported from the data table to be imported, row by row, in the direction from the starting point to the ending point, into the preset data model with a tree structure to obtain an import data tree. The advantage of this setup is that the data table to be imported is validated before storing the data into the preset data model, avoiding import errors due to incorrect header structure and attribute definitions of attribute fields, thus preventing disruption to data import efficiency.

[0048] The header structure validation can include determining whether a start and end point exist, and whether the number of intermediate nodes is correct. Attribute definition validation can, for example, determine whether the attribute fields in each intermediate node are predefined valid attribute columns. For example, the correct header structure and attribute field definitions of the template table to be imported can be pre-stored in the electronic device. During validation, the header structure of the current data table to be imported is compared with the header structure stored in the electronic device, and the attribute field definitions of the current data table to be imported are compared with the attribute field definitions stored in the electronic device. If all are consistent, the validation passes; if at least one is inconsistent, the validation fails. Optionally, if it fails, an exception can be thrown, such as performing a first alert operation to inform the user that there is a problem with the current data table to be imported. Specifically, a first alert message can be displayed, which may include items that failed validation, such as the header structure or attribute definitions.

[0049] In some embodiments, before converting the imported data tree into a database table in a preset database, the method further includes: performing content verification on the data content of each tree node in the imported data tree based on preset business rules, and determining whether to convert the imported data tree into a database table in the preset database based on the content verification result; wherein, converting the imported data tree into a database table in the preset database includes: converting the imported data tree into a database table in the preset database if the content verification result is satisfactory. The advantage of this setting is that, before persistent storage, the data content is verified based on preset business rules, ensuring the accuracy of the imported data.

[0050] For example, preset business rules can be set according to actual business needs. For instance, if the attribute of a certain attribute field is defined as a device number, and the preset business rule stipulates that the device number is N characters, then the data content of the corresponding data to be imported is checked to see if it is N characters. If it is, the check passes; otherwise, the check fails.

[0051] In some embodiments, converting the imported data tree into a database table in a preset database includes: determining the current level to be converted according to a preset order, wherein the preset order includes the order of each level in the imported data tree from the root node to the leaf node, which are sequentially determined as the current level; determining the first level identifier corresponding to the current level; storing the data stored on the tree nodes of the current level into a first database table; determining whether the current level has a previous level, and if so, obtaining the second level identifier corresponding to the previous level and storing the second level identifier in a target column of the first database table, wherein the target column is used to store the hierarchical relationship between the first database table and the second database table corresponding to the previous level. The advantage of this setup is that it can accurately store the data stored at each level of the imported data tree into the database table.

[0052] For example, starting from the first level of the tree node under the root node, the current level is determined sequentially until the level of the leaf node is reached. The level identifier can be a level number, such as the first level. If the current level is the first level and there is no previous level, then it is not necessary to store the association relationship of the previous level in the current first database table. If the current level is the second level and its previous level is the first level, then the second level identifier corresponding to the first level can be obtained and stored in the target column of the first database table.

[0053] In some embodiments, determining the first-level identifier corresponding to the current level includes: generating a first-level identifier corresponding to the current level using a preset identifier generation algorithm, wherein the preset identifier generation algorithm includes at least one of the snowflake algorithm, hash algorithm, and sequential numbering. The advantage of this configuration is that it can quickly and accurately generate unique level identifiers, ensuring the accuracy of the relationships between database tables.

[0054] In some embodiments, after converting the imported data tree into a database table in a preset database to achieve persistent storage of the data to be imported, the method further includes: determining a visual tree chart based on the imported data tree; and displaying the visual tree chart in a preset interface. The advantage of this setup is that after importing the data, the imported data is displayed in a tree structure on the interface through a corresponding functional interface, allowing business personnel to easily and quickly determine the accuracy of the imported data based on the displayed data. The preset interface can be an interface displayed on an electronic device.

[0055] Figure 2 This is a flowchart of another data import method provided by an embodiment of the present invention. The embodiment of the present invention optimizes the above-mentioned optional solutions, such as... Figure 2 As shown, the method includes:

[0056] Step 201: Determine the template table to be imported and obtain the data to be imported.

[0057] The header structure of the template table to be imported includes a starting point, at least two intermediate nodes, and an ending point. Each intermediate node stores a single row of data to be imported, corresponding to at least one record in the database table. Each intermediate node includes multiple attribute fields, and these attribute fields have a pre-defined mapping relationship with the table fields in the database table. In the at least two intermediate nodes, each intermediate node contains the same number of attribute fields and has the same attribute definitions.

[0058] For example, taking the cost-sharing task scenario as an example, the template table to be imported can be set as shown in Table 1 below:

[0059] Table 1: Templates to be imported

[0060]

[0061] For ease of explanation, as shown in Table 1 above, taking a table header structure with two intermediate nodes as an example, in actual application scenarios, more intermediate nodes can be set, and the specific number is not limited, avoiding the limitation of only allowing a specific number of levels of import and increasing scalability.

[0062] Step 202: Fill the corresponding cells in the template table to be imported with the data to be imported, according to the header structure and attribute field definitions in the template table to be imported, to obtain the data table to be imported.

[0063] For example, data content can be obtained from the system corresponding to each intermediate node as the data to be imported. According to the header structure and attribute field definition in the template table to be imported, the data can be filled into the corresponding cells to form the data table to be imported.

[0064] Step 203: Validate the header structure and attribute field definitions of the data table to be imported.

[0065] Step 204: If the verification passes, the data to be imported from the data table will be stored row by row in the direction from the start point to the end point into the preset data model of the tree structure to obtain the imported data tree.

[0066] For example, Figure 3 This is a schematic diagram of an imported data tree structure provided in an embodiment of the present invention, in conjunction with Table 1 and... Figure 3The process begins by storing the first row of data from intermediate node 1 into the first tree node (the parent node in the diagram, meaning the first tree node is now the parent node) under the root node in the preset data model of the tree structure. The first row of data from intermediate node 2 is then stored into the first child node (child node 1) under the first tree node. This process continues until the first row of data to be imported into the data table is stored. Next, since intermediate node 1 contains only one row while intermediate node 2 contains multiple rows, the second row of data in intermediate node 1 is empty. The second row of data from intermediate node 2 is then stored into the second child node (child node 2) under the first tree node. This process continues until the second row of data to be imported into the data table is stored. This process is repeated for each node: the third row of data from intermediate node 2 is stored into the third child node (child node 3) under the first tree node, and the fourth row of data from intermediate node 2 is stored into the fourth child node (child node 4) under the first tree node.

[0067] Step 205: Based on preset business rules, perform content verification on the data content of each tree node in the imported data tree, and determine whether to convert the imported data tree into a database table in the preset database based on the content verification results.

[0068] Step 206: If the content verification result is passed, determine the current level to be converted according to the preset order, determine the first level identifier corresponding to the current level, store the data stored on the tree node of the current level into the first database table according to the preset mapping relationship, determine whether there is a previous level for the current level, if there is, obtain the second level identifier corresponding to the previous level, and store the second level identifier in the target column of the first database table.

[0069] The preset order includes the order of each level in the imported data tree from the root node to the leaf node, which are determined as the current level in sequence; the target column is used to store the association relationship between the first database table and the second database table corresponding to the previous level.

[0070] Optionally, a preset identifier generation algorithm can be used to generate the first-level identifier corresponding to the current level in memory.

[0071] For example, such as Figure 3As shown in the diagram, the parent node represents the first level, and the four child nodes represent the second level. First, the parent node is set as the current level, and the snowflake algorithm is used to generate the corresponding first-level identifier. The data stored on the parent node is then stored in the first database table. Since there is no parent level, it is not necessary to store the identifier corresponding to the association relationship. Next, the four child nodes are set as the current level, and the snowflake algorithm is used to generate the corresponding second-level identifier. The four data entries stored on the four child nodes are then stored in the second database table. Because a parent level exists, the first-level identifier corresponding to the parent node is stored in the target column of the second database table to store the association relationship between the second and first database tables.

[0072] Step 207: Determine the visual tree chart based on the imported data tree, and display the visual tree chart in the preset interface.

[0073] For example, the structure of a visual tree diagram can be compared with... Figure 3 The structure is similar to that in the example, where each tree node can display specific data content, making it convenient for users to view the relationships between different data items.

[0074] The data import method provided in this invention predefines the field attributes of each intermediate node and the preset mapping relationship between the attribute fields and table fields to form an import template table. Data with relationships to be imported is stored in each intermediate node of a unified import data table. The order of the intermediate nodes in the header structure of the import data table reflects the relationships between the data stored in each intermediate node. During data import, format validation is performed first, then the data to be imported from the import data table is stored row by row into the import data tree. After validating the data content based on business rules, the data is imported according to the import data tree. The system sequentially and persistently stores the valid data stored on each tree node at the same level, imports it into the database table, and automatically generates a level identifier as a relational key to store the relationship between the database tables. After importing the data, a visual tree chart is displayed through a preset interface, making it easy for users to verify the accuracy of the data import. By adopting a flexible tree structure import format, it avoids building relational data in the form of technical primary keys in traditional import methods. This allows business personnel to only understand the business content without having to check the relational relationship based on technical fields, ensuring the efficiency and accuracy of data import.

[0075] Figure 4 This is a schematic diagram of the structure of a data import device provided in an embodiment of the present invention, as shown below. Figure 4 As shown, the device includes:

[0076] The data table acquisition module 401 is used to acquire the data table to be imported, wherein the header structure of the data table to be imported includes a starting point, at least two intermediate nodes, and an ending point in sequence, and the single row of data to be imported stored in each intermediate node corresponds to at least one data in the database table.

[0077] The data storage module 402 is used to store the data to be imported from the data table to be imported, row by row, in the direction from the starting point to the ending point into a preset data model of a tree structure to obtain an import data tree. In this model, for each pair of adjacent intermediate nodes in the header structure, the intermediate node closer to the starting point corresponds to the parent node in the import data tree, and the intermediate node farther from the starting point corresponds to the child node in the import data tree.

[0078] The data tree conversion module 403 is used to convert the imported data tree into a database table in a preset database to achieve persistent storage of the data to be imported. The different levels of tree nodes in the imported data tree correspond to different database tables, and the relationship between different database tables is determined according to the hierarchical relationship of the imported data tree.

[0079] The data import device provided in this embodiment of the invention acquires a data table to be imported. The header structure of the data table to be imported includes a starting point, at least two intermediate nodes, and an ending point. Each intermediate node stores a single row of data to be imported, which corresponds to at least one data record in a database table. The data to be imported in the data table is stored row by row in a tree-structured preset data model from the starting point to the ending point to obtain an import data tree. For every two adjacent intermediate nodes in the header structure, the intermediate node closer to the starting point corresponds to the parent node in the import data tree, and the intermediate node farther from the starting point corresponds to the child node in the import data tree. The import data tree is converted into a database table in a preset database to achieve persistent storage of the data to be imported. Different levels of tree nodes in the import data tree correspond to different database tables, and the relationship between different database tables is determined according to the hierarchical relationship of the import data tree. By adopting the above technical solution, the data to be imported that has a relationship is stored in the intermediate nodes of a unified data table to be imported. The relationship between the data to be imported stored in each intermediate node is reflected by the order of the intermediate nodes in the header structure of the data table to be imported. There is no need to use additional columns to identify row records and store identifiers representing parent-child relationships. This can more intuitively reflect the data relationship and reduce errors. When importing data, the data to be imported in the data table is first stored row by row into the import data tree, and then the import data tree is converted into a database table. This can achieve persistent storage of the data to be imported, ensuring the efficiency and accuracy of data import.

[0080] Optionally, the intermediate node includes multiple attribute fields, and the attribute fields and the table fields in the database table have a preset mapping relationship;

[0081] Specifically, the data tree conversion module is used for:

[0082] Based on the preset mapping relationship, the imported data tree is converted into a database table in the preset database.

[0083] Optionally, the preset mapping relationship includes a one-to-one mapping relationship or a one-to-many mapping relationship;

[0084] Specifically, for the case where the preset mapping relationship is a one-to-many mapping relationship:

[0085] If the table structure of the database table is a narrow table, then one piece of data to be imported under one attribute field corresponds to multiple pieces of data under the same table field in the database table;

[0086] If the table structure of the database table is a wide table, then one attribute field corresponds to multiple table fields in the database table.

[0087] Optionally, in the at least two intermediate nodes, each intermediate node contains the same number of attribute fields and the attribute definitions are the same.

[0088] Optionally, the data table acquisition module includes:

[0089] The template determination unit is used to determine the template table to be imported;

[0090] The data acquisition unit is used to acquire the data to be imported.

[0091] The data entry unit is used to fill the data to be imported into the corresponding cells of the template table to be imported, according to the header structure and attribute field definitions of the template table to be imported, so as to obtain the data table to be imported.

[0092] Optionally, the data storage module includes:

[0093] The table verification unit is used to verify the header structure and attribute definitions of the attribute fields of the data table to be imported.

[0094] The data storage unit is used to, if the verification passes, store the data to be imported from the data table to be imported row by row into a preset data model of tree structure in the direction from the starting point to the ending point, so as to obtain the imported data tree.

[0095] Optionally, the device may also include:

[0096] The data content verification module is used to verify the data content of each tree node in the imported data tree based on preset business rules before converting the imported data tree into a database table in the preset database, and to determine whether to convert the imported data tree into a database table in the preset database based on the content verification results.

[0097] Specifically, the data tree conversion module is used for:

[0098] If the content verification result is satisfactory, the imported data tree will be converted into a database table in the preset database.

[0099] Optionally, the data tree transformation module includes:

[0100] The current level determination unit is used to determine the current level to be converted according to a preset order, wherein the preset order includes the order of each level in the imported data tree from the root node to the leaf node of the imported data tree, which are determined as the current level in sequence;

[0101] A hierarchy identifier determination unit is used to determine the first hierarchy identifier corresponding to the current hierarchy.

[0102] The storage unit is used to store the data stored on the tree node of the current level into the first database table;

[0103] An identifier storage unit is used to determine whether there is a previous level in the current level. If there is, the identifier of the second level corresponding to the previous level is obtained and stored in the target column of the first database table. The target column is used to store the association relationship between the first database table and the second database table corresponding to the previous level.

[0104] Optionally, the hierarchy identifier determination unit is specifically used for:

[0105] A first-level identifier corresponding to the current level is generated using a preset identifier generation algorithm, wherein the preset identifier generation algorithm includes at least one of the snowflake algorithm, hash algorithm, and sequential numbering.

[0106] Optionally, the device may also include:

[0107] The tree chart determination module is used to determine a visual tree chart based on the imported data tree after converting the imported data tree into a database table in a preset database to achieve persistent storage of the data to be imported.

[0108] The chart display module is used to display the visual tree chart in a preset interface.

[0109] Optionally, the data to be imported includes data from the cost allocation task, the starting point includes the cost pool, and the ending point includes the account.

[0110] Figure 5 A schematic diagram of an electronic device 10 that can be used to implement embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.

[0111] like Figure 5 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 may also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0112] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0113] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as data import methods.

[0114] In some embodiments, the data import method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or mounted on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the data import method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the data import method by any other suitable means (e.g., by means of firmware).

[0115] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0116] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0117] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0118] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0119] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.

[0120] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.

[0121] This invention also provides a computer program product, including a computer program that, when executed by a processor, implements the data import method provided in any embodiment of this application.

[0122] In implementing the computer program product, computer program code for performing the operations of this invention can be written in one or more programming languages ​​or a combination thereof. Programming languages ​​include object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0123] Note that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.

Claims

1. A data import method, characterized in that, include: Obtain the data table to be imported, wherein the header structure of the data table to be imported includes a starting point, at least two intermediate nodes, and an ending point in sequence, and the single row of data to be imported stored in each intermediate node corresponds to at least one data in the database table; The data to be imported from the data table to be imported is stored row by row in a tree-structured preset data model from the starting point to the ending point to obtain an import data tree. The tree structure of the preset data model corresponds to the table header structure. For each pair of adjacent intermediate nodes in the table header structure, the intermediate node closer to the starting point corresponds to the parent node in the import data tree, and the intermediate node farther from the starting point corresponds to the child node in the import data tree. The imported data tree is converted into a database table in a preset database to achieve persistent storage of the imported data. Different levels of tree nodes in the imported data tree correspond to different database tables, and the relationship between different database tables is determined according to the hierarchical relationship of the imported data tree. The step of converting the imported data tree into a database table in a preset database includes: The current level to be converted is determined according to a preset order, wherein the preset order includes the order of each level in the imported data tree from the root node to the leaf node of the imported data tree, and these levels are determined as the current level in sequence. A first-level identifier corresponding to the current level is generated using a preset identifier generation algorithm, wherein the preset identifier generation algorithm includes at least one of snowflake algorithm, hash algorithm and sequential numbering; Store the data stored on the tree node at the current level into the first database table; Determine whether the current level has a previous level. If it does, obtain the second level identifier corresponding to the previous level and store the second level identifier in the target column of the first database table. The target column is used to store the association relationship between the first database table and the second database table corresponding to the previous level.

2. The method according to claim 1, characterized in that, The intermediate node includes multiple attribute fields, and the attribute fields and the table fields in the database table have a preset mapping relationship; The step of converting the imported data tree into a database table in a preset database includes: Based on the preset mapping relationship, the imported data tree is converted into a database table in the preset database.

3. The method according to claim 2, characterized in that, The preset mapping relationship includes a one-to-one mapping relationship or a one-to-many mapping relationship; Specifically, for the case where the preset mapping relationship is a one-to-many mapping relationship: If the table structure of the database table is a narrow table, then one piece of data to be imported under one attribute field corresponds to multiple pieces of data under the same table field in the database table; If the table structure of the database table is a wide table, then one attribute field corresponds to multiple table fields in the database table.

4. The method according to claim 2, wherein the characteristic root is, In the at least two intermediate nodes, each intermediate node contains the same number of attribute fields and the attribute definitions are the same.

5. The method according to claim 2, characterized in that, The process of obtaining the data table to be imported includes: Identify the template table to be imported; Get the data to be imported; The data to be imported is filled into the corresponding cells of the template table according to the header structure and attribute field definitions of the template table to be imported, thus obtaining the data table to be imported.

6. The method according to claim 2, characterized in that, The step of storing the data to be imported from the data table to be imported, row by row, in a tree-structured preset data model from the starting point to the ending point, to obtain the imported data tree includes: The header structure and attribute field definitions of the data table to be imported are validated. If the verification passes, the data to be imported from the data table to be imported will be stored row by row in the direction from the starting point to the ending point into the preset data model of the tree structure to obtain the imported data tree.

7. The method according to claim 1, characterized in that, Before converting the imported data tree into a database table in the preset database, the process also includes: Based on preset business rules, the data content of each tree node in the imported data tree is validated, and the imported data tree is converted into a database table in the preset database based on the content validation results. The step of converting the imported data tree into a database table in a preset database includes: If the content verification result is satisfactory, the imported data tree will be converted into a database table in the preset database.

8. The method according to claim 1, characterized in that, After converting the imported data tree into a database table in a preset database to achieve persistent storage of the imported data, the method further includes: Based on the imported data tree, determine the visual tree chart; The visual tree diagram is displayed in the preset interface.

9. The method according to claim 1, characterized in that, The data to be imported includes data from the cost allocation task, the starting point includes the cost pool, and the ending point includes the account.

10. A data import device, characterized in that, include: The data table acquisition module is used to acquire the data table to be imported. The header structure of the data table to be imported includes a starting point, at least two intermediate nodes, and an ending point. Each intermediate node stores a single row of data to be imported, which corresponds to at least one data in the database table. The data storage module is used to store the data to be imported from the data table to be imported, row by row, in the direction from the starting point to the ending point into a preset data model of tree structure to obtain an import data tree. The tree structure of the preset data model corresponds to the table header structure. For every two adjacent intermediate nodes in the table header structure, the intermediate node closer to the starting point corresponds to the parent node in the import data tree, and the intermediate node farther from the starting point corresponds to the child node in the import data tree. The data tree conversion module is used to convert the imported data tree into database tables in a preset database to achieve persistent storage of the data to be imported. The different levels of tree nodes in the imported data tree correspond to different database tables, and the relationship between different database tables is determined according to the hierarchical relationship of the imported data tree. The data tree conversion module includes: The current level determination unit is used to determine the current level to be converted according to a preset order, wherein the preset order includes the order of each level in the imported data tree from the root node to the leaf node of the imported data tree, which are determined as the current level in sequence; A hierarchy identifier determination unit is used to determine the first hierarchy identifier corresponding to the current hierarchy. The storage unit is used to store the data stored on the tree node of the current level into the first database table; An identifier storage unit is used to determine whether there is a previous level in the current level. If there is, the identifier of the second level corresponding to the previous level is obtained and stored in the target column of the first database table. The target column is used to store the association relationship between the first database table and the second database table corresponding to the previous level. The hierarchy identifier determination unit is specifically used for: A first-level identifier corresponding to the current level is generated using a preset identifier generation algorithm, wherein the preset identifier generation algorithm includes at least one of the snowflake algorithm, hash algorithm, and sequential numbering.

11. An electronic device, characterized in that, The invention includes a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor, when executing the computer program, implements the method as described in any one of claims 1-9.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-9.

13. A computer program product, comprising a computer program, characterized in that, The computer program, when executed by a processor, implements the method as described in any one of claims 1-9.