File analysis method

By structuring and templated operations on the parsed files and splitting them into multiple unit template files, the problem of low flexibility in file parsing methods in the existing technology is solved, and flexible analysis of tree structure files with different file structures is realized.

CN119578403APending Publication Date: 2025-03-07NO 15 INST OF CHINA ELECTRONICS TECH GRP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411637162.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-15
Publication Date
2025-03-07

AI Technical Summary

Technical Problem

In the prior art, the file parsing method is low in flexibility and cannot adapt to changes in the tree structure file format, resulting in inaccurate parsing.

Method used

By obtaining the collection of files to be parsed and the target data type, performing structured and templated operations, converting them into tree structure files, and splitting them into multiple unit template files to achieve flexible target parsing.

Benefits of technology

It improves the flexibility of file parsing methods, can adapt to the parsing of tree structure files with different file structures, and ensures parsing accuracy and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119578403A_ABST
    Figure CN119578403A_ABST
Patent Text Reader

Abstract

The invention provides a file analysis method, and relates to the technical field of file analysis. The method specifically comprises the steps of obtaining a to-be-analyzed file and a target data type set, wherein the to-be-analyzed file comprises a reference data set and multiple reference data types corresponding to the reference data set; structured operation is conducted on the target data type set according to the to-be-analyzed file, a target structure file is obtained, and the structured operation is used for converting the target data type set into a tree structure file; templating operation is conducted on the target structure file to obtain a plurality of unit template files, and the templating operation is used for splitting structure information in the target structure file into a plurality of files meeting a preset structure; and performing target analysis on the to-be-analyzed file according to the plurality of unit template files to obtain a target data file. The problem that in the prior art, a file analysis method is low in flexibility is solved, and the flexibility of the file analysis method is 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 file parsing, and in particular to a file parsing method. Background Art

[0002] File parsing is the process of extracting and analyzing data from files. The files used for parsing include various types and structures, such as text files, log files, tree structure files, XML files, JSON files, etc. Through file parsing, the required information can be effectively extracted from a large amount of data for more in-depth analysis and processing. The parsing method for files of different types and structures usually adopts the parsing method that best matches their type and structure to achieve parsing while ensuring accuracy and efficiency.

[0003] For a tree-structured file, in order to parse out the required data, parsing all the data from the tree-structured file will result in more parsed data and will affect the parsing efficiency. Therefore, in order to parse out the required data with less parsing of the data in the tree-structured file, the prior art usually adopts a fixed parsing method for the data on certain layers of the tree-structured file, such as only parsing the third-layer nodes and the fourth-layer nodes of the entire tree-structured file. However, this method cannot accurately parse out the required data when the format of the tree-structured file changes (for example, the number of node layers where the same data in the tree-structured file is located changes). In this case, the parsing logic (for example, the number of parsing layers) needs to be modified. Obviously, the flexibility of this parsing method is very limited.

[0004] With regard to the problem of low flexibility of the file parsing method in the prior art, no effective technical solution has been proposed yet. Summary of the invention

[0005] The embodiment of the present application provides a file parsing method to at least solve the problem of low flexibility of the file parsing method in the prior art.

[0006] According to one aspect of an embodiment of the present application, a file parsing method is provided, including: obtaining a file to be parsed and a target data type set, wherein the file to be parsed includes a reference data set and multiple reference data types corresponding to the reference data set, the target data type set includes multiple target data types, and the target data set corresponding to the multiple target data types is a subset of the reference data set; performing a structuring operation on the target data type set according to the file to be parsed to obtain a target structure file, wherein the structuring operation is used to convert the target data type set into a tree structure file; performing a template operation on the target structure file to obtain a plurality of unit template files, wherein the template operation is used to split the structural information in the target structure file into a plurality of files that meet a preset structure; performing target parsing on the file to be parsed according to the plurality of unit template files to obtain a target data file, wherein the target data file includes multiple target data types, a target data set, and a correspondence between target data corresponding to the multiple target data types in the file to be parsed.

[0007] According to another aspect of an embodiment of the present application, a file parsing device is also provided, including: an acquisition unit, used to acquire a file to be parsed and a target data type set, wherein the file to be parsed includes a reference data set and multiple reference data types corresponding to the reference data set, and the target data type set includes multiple target data types, and the target data set corresponding to the multiple target data types is a subset of the reference data set; a structuring unit, used to perform a structuring operation on the target data type set according to the file to be parsed to obtain a target structure file, wherein the structuring operation is used to convert the target data type set into a tree structure file; a template unit, used to perform a template operation on the target structure file to obtain a plurality of unit template files, wherein the template operation is used to split the structural information in the target structure file into a plurality of files that meet a preset structure; a parsing unit, used to perform target parsing on the file to be parsed according to the plurality of unit template files to obtain a target data file, wherein the target data file includes multiple target data types, a target data set, and a correspondence between target data corresponding to the multiple target data types in the file to be parsed.

[0008] Optionally, the above-mentioned template unit includes a judgment unit, which is used to judge whether the target root node has child nodes, and prompt exception information when the target root node has no child nodes, wherein the target root node is the root node of the target structure file, and the exception information is used to indicate the target data type set, and / or the exception of the file to be parsed; a creation unit, which is used to create a first unit template file when the target root node has child nodes, and determine the name of the first root node as the name of the target root node, wherein the first root node is the root node of the first unit template file; a first acquisition sub-unit, which is used to obtain a first child node set corresponding to the target root node, and update the first unit template file according to the first node types respectively corresponding to the multiple first child nodes included in the first child node set; a determination unit, which is used to determine the first unit template file obtained by the update operation as the first unit template file, and determine multiple unit template files based on the first unit template file.

[0009] Optionally, the above-mentioned determination unit includes a first creation sub-unit, used to create a target queue and enqueue the first unit template file at the end of the target queue; a judgment sub-unit, used to judge whether the target queue is empty, and when the target queue is a non-empty queue, obtain multiple head sub-nodes of the head unit template file, wherein the head unit template file is a unit template file located at the head of the target queue; a target operation unit, used to perform target operations on multiple head sub-nodes to obtain multiple unit template files; and a control unit, used to control the head unit template file to exit the target queue.

[0010] Optionally, the target operation unit includes a first determination subunit, used to determine any one of multiple team head subnodes as a second child node; a second creation subunit, used to create a second unit template file corresponding to the second child node, and queue the second unit template file at the end of the target queue; a second acquisition subunit, used to obtain the node name on the target structure file corresponding to the first address of the second child node, obtain a reference name, and determine the name of the second root node as the reference name, wherein the second root node is the root node of the second unit template file; a modification subunit, used to modify the first address of the second child node to the template address of the second unit template file, and determine the nodes among the multiple team head subnodes other than the second child node that have not performed the target operation as the second child node.

[0011] Optionally, the above-mentioned parsing unit includes: a third acquisition sub-unit, used to acquire the root node names of multiple unit template files to obtain multiple unit root node names; a second determination sub-unit, used to determine the unit template file corresponding to the unit root node name that matches the file root node name among the multiple unit root node names as the target unit template file; a reference parsing sub-unit, used to perform a reference parsing operation on the file to be parsed according to the target unit template file to obtain a first data file; and a third determination sub-unit, used to determine the target data file based on the first data file.

[0012] Optionally, the above-mentioned third determination sub-unit includes: a first acquisition module, used to obtain multiple leaf nodes corresponding to the first data file; a first update module, used to update the attributes of the preset leaf node when there is a preset leaf node that meets the preset attributes among the multiple leaf nodes, and obtain a leaf node template and a sub-file with the file node as the root node, wherein the leaf node template is a unit template file corresponding to the preset leaf node, and the file node is a node in the file to be parsed corresponding to the preset leaf node; a reference parsing module, which performs a reference parsing operation on the sub-file according to the leaf node template to obtain the second data file, and replaces the preset leaf node with the root node of the second data file; the first determination module, used to determine the first data file as the target data file when there is no preset leaf node that meets the preset attributes among the multiple leaf nodes.

[0013] Optionally, the above-mentioned reference parsing sub-unit includes: a creation module, used to create a first reference data file; a second acquisition module, used to acquire the node in the file to be parsed corresponding to the root node of the target unit template file, obtain the first reference node, and determine the name of the first reference data file as the name of the first reference node; a third acquisition module, used to acquire the reference root node of the target unit template file and multiple reference sub-nodes in the target unit template file; a second determination module, used to determine the first data file based on the reference root node, multiple reference sub-nodes, the file to be parsed and the first reference data file.

[0014] Optionally, the above-mentioned second determination module includes: a first determination submodule, used to determine multiple index paths based on a reference root node and multiple reference subnodes; a second determination submodule, used to determine multiple third subnodes from the file to be parsed based on the multiple index paths, wherein each index path corresponds to a third subnode; a second update module, used to update the first reference data file according to the second node types and multiple third subnodes corresponding to each of the multiple reference subnodes, and determine the updated first reference data file as the first data file.

[0015] Optionally, the above-mentioned second update module includes: a first creation submodule, which is used to create multiple address subnodes for the first reference data file according to multiple third subnodes when the second node type indicates that the reference subnode is a non-leaf node, and respectively construct address attributes and template attributes for the multiple address subnodes, wherein each address subnode corresponds to a third subnode; a storage submodule, which is used to store the third subnode address corresponding to the address attribute in the address attribute, and store the address of the reference subnode in the template attribute, wherein the third subnode address is the address of the third subnode corresponding to the address subnode; a second creation submodule, which is used to create multiple data subnodes for the first reference data file according to multiple third subnodes when the second node type indicates that the reference subnode is a leaf node, and store the data corresponding to the multiple third subnodes in the multiple data subnodes respectively, wherein each data subnode corresponds to a third subnode.

[0016] Optionally, the above-mentioned structuring unit includes: a third creation sub-unit, used to create a reference structure file, and determine the root node name of the reference structure file as the root node name of the file to be parsed; a fourth determination sub-unit, used to determine the index lengths corresponding to multiple target data types according to a preset data set, wherein the preset data set includes multiple preset data types and the correspondence between each preset data type, and the multiple preset data types include multiple target data types; the fourth creation sub-unit, used to create a child node under the root node of the reference structure file according to the index length corresponding to the file to be parsed and each target data type; and a fifth determination sub-unit, used to determine the obtained reference structure file as the target structure file.

[0017] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the above file parsing method.

[0018] According to another aspect of the embodiments of the present application, an electronic device is also provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor executes the file parsing method as described above.

[0019] Through the above file parsing method, tree structure files of different file structures can be parsed, thereby improving the flexibility of the file parsing method. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the specific implementation methods of the present application or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some implementation methods of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0021] Figure 1 is a flowchart of an optional file parsing method according to an embodiment of the present invention;

[0022] Figure 2 is a schematic diagram of an optional file to be parsed according to an embodiment of the present invention;

[0023] Figure 3 is a flow chart of an optional structured operation according to an embodiment of the present invention;

[0024] Figure 4 is a schematic diagram of an optional target structure file according to an embodiment of the present invention;

[0025] Figure 5 is a flow chart of an optional templated operation according to an embodiment of the present invention;

[0026] Figure 6 is a schematic diagram of another optional file parsing method according to an embodiment of the present invention;

[0027] Figure 7 is a flowchart of another optional file parsing method according to an embodiment of the present invention;

[0028] Figure 8 is a flowchart of another optional file parsing method according to an embodiment of the present invention;

[0029] Fig. 9 is a schematic diagram of another optional file parsing method according to an embodiment of the present invention;

[0030] Fig.10 is a schematic diagram of yet another optional file parsing method according to an embodiment of the present invention. DETAILED DESCRIPTION

[0031] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described 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 should fall within the scope of protection of the present application.

[0032] It should be noted that the terms "first", "second", etc. in the specification and claims 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. 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 units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices. It should be noted that, in the absence of conflict, the embodiments in the present application and the features in the embodiments can be combined with each other. The present application will be described in detail below with reference to the drawings and in conjunction with the embodiments.

[0033] Before introducing the technical solution of this application, some background technical knowledge involved in this application is first introduced and explained. The following related technologies can be combined arbitrarily with the technical solution of the embodiment of this application as optional solutions, and they all belong to the protection scope of the embodiment of this application. The embodiment of this application includes at least part of the following contents.

[0034] Tree structure file: used to represent a data set with a hierarchical relationship. It has the characteristics of hierarchical nesting. It is similar to an upside-down tree, with the root facing up and the leaves facing down. There is a one-to-many relationship between nodes, that is, a node can have multiple child nodes, but except for the root node, each node has one and only one predecessor node (that is, the previous node of a certain node). The tree structure file includes nodes (the basic building block of the tree, which can contain data and other information, and each node can have zero or more child nodes), root nodes (the top node of the tree, without a parent node, is the starting point of the entire tree), child nodes (each node can have one or more child nodes), parent nodes (each node except the root node has a direct parent node), leaf nodes (nodes without child nodes, located at the bottom of the tree), paths (a series of continuous edges from one node to another), depth (the length of the path from a node to the root node, the depth of the root node is 0), and height (the height of the tree refers to the longest path length from the root node to the farthest leaf node).

[0035] ATO (Air Task Order): A means of issuing or conveying instructions to functional departments, subordinate units and command organizations that are ready to go, capable of going out or have already gone out to perform tasks. ATO is essentially a tree-structured file written in XML language. ATO is highly formatted, has a huge amount of information and has large content changes.

[0036] At present, there are usually two ways to parse tree-structured files. The first way is to parse out all the data in the tree-structured file (that is, to parse the data on all nodes in the file), and the second way is to parse the data on certain layers of the file (that is, to fix the node layer of the parsing, such as parsing the data on the third and fourth level nodes). However, the first way will result in more parsing content, slow parsing speed, and further screening of all the parsed data is required to obtain the required data; and the second way is that when the number of node layers where the same data is located changes (that is, the format of the tree-structured file changes, such as the same data is changed from the storage of the third-level node to the storage of the fourth-level node), the parsing method of the original tree-structured file cannot accurately parse the required data from the changed tree-structured file. It can be seen from this that the existing file parsing methods often rely on the specific format of a tree-structured file. When the format of the tree-structured file changes, such as adjusting the field hierarchy (that is, modifying the same data from a certain level of node to another level of node for storage), the parsing logic of the tree-structured file needs to be changed. As the input of the computer system, the tree structure file needs to read its content. When the tree structure file changes, the computer system source code often needs to be modified, which causes great trouble to system maintenance because the client of the computer system may not have the conditions to compile the source code. That is, the existing file parsing method cannot flexibly cope with the parsing of the tree structure file that changes at any time.

[0037] In order to solve the above problems, the present application provides a file parsing method. As an optional implementation, the above file parsing method can be, but is not limited to, a file parsing system composed of a terminal device and a server. The present application does not limit the specific structure of the file parsing system.

[0038] As an optional implementation, please refer to Figure 1 The flowchart of the file parsing method shown in FIG. The method may include the following steps:

[0039] S102, obtaining a file to be parsed and a target data type set, wherein the file to be parsed includes a reference data set and multiple reference data types corresponding to the reference data set, the target data type set includes multiple target data types, and the target data set corresponding to the multiple target data types is a subset of the reference data set;

[0040] S104, performing a structural operation on the target data type set according to the file to be parsed to obtain a target structure file, wherein the structural operation is used to convert the target data type set into a tree structure file;

[0041] S106, performing a template operation on the target structure file to obtain a plurality of unit template files, wherein the template operation is used to split the structure information in the target structure file into a plurality of files satisfying a preset structure;

[0042] S108, performing target parsing on the file to be parsed according to the multiple unit template files to obtain a target data file, wherein the target data file includes multiple target data types, a target data set, and corresponding relationships between target data corresponding to the multiple target data types in the file to be parsed.

[0043] The file to be parsed in S102 is a tree-structured file, which includes a large amount of data (i.e., the reference data set) and the data type corresponding to each reference data in the reference data set (i.e., the multiple reference data types), including the required data (i.e., the target data set), and the target data type set includes multiple target data types (which can be understood as, but not limited to, the data types corresponding to the required data). The file to be parsed in S102 can be understood as, but not limited to, a tree-structured file including multiple nodes, and the multiple target data types included in the target data type set can be understood as, but not limited to, multiple nodes to be parsed.

[0044] The operation in S104 can be understood, but not limited to, as follows: the target data type set includes multiple target data types in the form of a set (the target data type set is represented by nodes such as {E, D, K}, where the set elements E, D, K are target data types, and each set element can also be understood, but not limited to, as a node name), and the structuring operation in S104 can be understood, but not limited to, as structuring the target data type set composed of the multiple target data types in the form of a set into a tree structure file (the target structure file), and each set element in the target data type corresponds to a node in the target structure file. The target structure file contains the structural information of the data.

[0045] The above S104 specifically includes: S1, creating a reference structure file, and determining the root node name of the reference structure file as the root node name of the file to be parsed; S2, determining the index lengths corresponding to multiple target data types according to a preset data set, wherein the preset data set includes multiple preset data types, and the correspondence between each preset data type, and the multiple preset data types include multiple target data types; S3, creating a child node under the root node of the reference structure file according to the index length corresponding to the file to be parsed and each target data type; S4, determining the obtained reference structure file as the target structure file.

[0046] The above creation of the reference structure file can be understood, but not limited to, as creating a tree structure file with only a root node. The above determination of the root node name of the reference structure file as the root node name of the file to be parsed can be understood, but not limited to, as naming the root node of the reference structure file, that is, naming the root node of the reference structure file as the root node name of the file to be parsed (it can also be understood as determining the data type corresponding to the root node of the reference structure file as the data type corresponding to the root node of the file to be parsed. The name determination operation or naming operation in the following description is similar to this, that is, the determination of the name is the specific determination of the data type corresponding to the root node); the above index length can be understood, but not limited to, as the length from the highest level to the target data type. In the above S2, index paths (paths corresponding to the index lengths) corresponding to multiple target data types are also determined according to a preset data set. The preset data set includes multiple preset data. Type, the correspondence between each of the above-mentioned preset data types can be but is not limited to being understood as a hierarchical relationship between multiple preset data types. The above S3 can be but is not limited to being understood as creating a child node under the root node of the reference structure file according to the index length, index path and file to be parsed. The multiple preset data types in the above-mentioned preset data set, such as {school, class, head teacher, table, chair}, have a hierarchical relationship of: school>class>head teacher>table, chair; assuming that the above-mentioned multiple target data types include head teacher and table, then the operation in the above S2, for example, determines the index length corresponding to the head teacher and the index length corresponding to the table according to the preset data set, then the result is: the index length corresponding to the head teacher is 3, the index path is from school to class, from class to head teacher, and the index length corresponding to the table is 4, and the index path is from school to class, from class to head teacher, and from head teacher to table.

[0047] The operations in S3-S4 can be understood, but are not limited to, as a process of searching the file to be parsed to determine whether the target data type exists based on multiple target data types and the index length corresponding to each target data type. If so, a child node is created for the reference structure file, and after all target data type sets are finally searched, the final reference structure file is determined as the target structure file.

[0048] The following Figure 2 and Figure 4 Take S1 to S4 as an example to explain in detail (ie S104 above):

[0049] Assume that Figure 2 The file to be parsed is shown below. Figure 2 Each circle shown represents each node in the file to be parsed, and the English letters in each node (such as Figure 2A, B, C, D, ... W) shown in the figure are the node names of each node (which can be understood as, but not limited to, the data type corresponding to each node), and the node names can be the same, that is, the data type corresponding to each node can be the same, for example, Figure 2 The two nodes named B and G shown are nodes corresponding to classes (i.e., data types) (for ease of description, the following description directly uses English letters to replace the description of nodes or data types). The operations in S1 to S4 above are as follows: Figure 3 As shown, specifically including:

[0050] S301 (i.e., S1 above), creates a reference structure file, and names the root node name of the reference structure file as the root node name of the file to be parsed; S302 (i.e., S2 above), determines the index length and index path corresponding to each target data type according to a preset data set; S303 (i.e., S3 above), traverses the index path and the file to be parsed according to the index length; S304 (i.e., S4 above), determines the obtained reference structure file as the target structure file.

[0051] Assume that the target data type set is {E, D, K}, the preset data type is {A, B, C, D......W}, and the corresponding relationship is A>B, G>C, E, L, M, N>D, F, O, P, Q, R, S, T, U, V, W>K. Figure 3 The result obtained in S302 is: the index length corresponding to E is 3, and the index path is A→B→E; the index length corresponding to D is 4, and the index path is A→B→C→D; the index length corresponding to K is 5, and the index path is A→B→C→F→K. Figure 3The 303 shown specifically includes: S303-1, determining any un-traversed index path (any index path among multiple index paths corresponding to multiple target data types) as the current index path; S303-2, using i to represent the index element in the current index path, k to represent the index length corresponding to the current index path, and setting i = 1; S303-3, judging whether there is a node corresponding to i in the reference structure file. In the case where there is no node corresponding to i, execute S303-4, create a child node under the node of the (i - 1)-th element in the reference structure file (which can be understood as, but not limited to, the node corresponding to the index node corresponding to the (i - 1)-th in the index path in the reference structure file), and name it as the node corresponding to i. In the case where there is a node corresponding to i, execute S303-5, i = i + 1; S303-6, judging whether i is greater than k. In the case where i is less than or equal to k, execute S303-3. In the case where i is greater than k, execute S303-7, judging whether the index path has been traversed. In the case where the index path has been traversed, execute S304, and determine the obtained reference structure file as the target structure file. In the case where the index path has not been traversed, execute S303-1.

[0052] Assume that the index paths corresponding to the above {E, D, K} are traversed respectively. The above S303-1 to S303-7 are as follows: Assume that the current index path is A→B→E. At this time, k = 3, when i = 1, the node corresponding to i is A (such as Figure 3 the index element shown), and the root node in the reference structure file is the A node (such as Figure 4 the A node shown). Therefore, execute S303-5 to get i = 2, i < k. At this time, the node corresponding to i is B, and there is no B node in the reference structure file. Therefore, execute S303-4, create a child node under the A node in the reference structure file, and name it B (at this time, a reference structure file including node A and node B is obtained); execute S303-5 to get i = 3, i = k. At this time, the node corresponding to i is E, and there are A node and B node in the reference structure file, but there is no E node. Therefore, execute S303-4, create a child node under the B node in the reference structure file, and name it E (at this time, a reference structure file including node A, node B and E node is obtained); execute S303-6, get i = 4, i > k. So far, the traversal of A→B→E is completed.

[0053] Determine A→B→C→D as the current index path. At this time, k = 4. Let i = 1. The node corresponding to i is A. Since the reference structure file includes node A, execute S303-5 to get i = 2. Since i < k, the node corresponding to i is B. Since the reference structure file includes node B, execute S303-5 to get i = 3. Since i < k, the node corresponding to i is C. Since the reference structure file does not include node C, execute S303-4. Create a child node under node B in the reference structure file and name it C (at this time, a reference structure file including node A, node B, node E, and node C is obtained); execute S303-5 to get i = 4. Since i = k, the node corresponding to i is D. Since the reference structure file does not include node D, execute S303-4. Create a child node under node C in the reference structure file and name it D (at this time, a reference structure file including node A, node B, node E, node C, and node D is obtained); execute S303-6 to get i = 5. Since i > k,至此, A→B→C→D traversal is completed.

[0054] Determine A→B→C→F→K as the current index path. At this time, k = 5. Let i = 1. The node corresponding to i is A. Since the reference structure file includes node A, execute S303-5 to get i = 2. Since i < k, the node corresponding to i is B. Since the reference structure file includes node B, execute S303-5 to get i = 3. Since i < k, the node corresponding to i is C. Since the reference structure file includes node C, execute S303-5 to get i = 4. Since i < k, the node corresponding to i is F. Since the reference structure file does not include node F, execute S303-4. Create a child node under node C in the reference structure file and name it F (at this time, a reference structure file including node A, node B, node E, node C, and node F is obtained); execute S303-5 to get i = 5. Since i = k, the node corresponding to i is K. Since the reference structure file does not include node K, execute S303-4. Create a child node under node F in the reference structure file and name it K (at this time, a reference structure file including node A, node B, node E, node C, node D, node F, and node K is obtained, that is, the target structure file as shown in Figure 4 ); execute S303-6 to get i = 6. Since i > k,至此, A→B→C→D traversal is completed.

[0055] The templating operation in S106 above can be but is not limited to understood as splitting the structural information of the target structure file into tree-structured files with only two layers (only the root node and child nodes) (i.e., the above unit template files). For example, for Figure 4The target structure file shown is split into multiple tree structure files with only two layers, wherein each non-leaf node corresponds to a unit template file, and each unit template file has a corresponding relationship. Then the multiple unit template files obtained are: node A corresponds to a unit template file, node B corresponds to a unit template file, node C corresponds to a unit template file, and node F corresponds to a unit template file.

[0056] The unit template file obtained in the above S106 includes the index information corresponding to each node, that is, it can be understood but not limited to that each unit template file includes an index path for parsing the target data from the file to be parsed, and the operation in the above S108 can be understood but not limited to that a specific parsing operation is performed on the file to be parsed according to the index paths in multiple unit template files, so as to obtain specific data, and retain the corresponding relationship between each data, so as to obtain the final target data file.

[0057] The above-mentioned file parsing method solves the problem of low flexibility of the file parsing method in the prior art and improves the flexibility of the file parsing method.

[0058] As an optional implementation, the above-mentioned template operation on the target structure file to obtain multiple unit template files includes: S1, determining whether the target root node has child nodes, and prompting exception information when the target root node has no child nodes, wherein the target root node is the root node of the target structure file, and the exception information is used to indicate the target data type set, and / or the exception of the file to be parsed; S2, when the target root node has child nodes, creating a first unit template file, and determining the name of the first root node as the name of the target root node, wherein the first root node is the root node of the first unit template file; S3, obtaining the first child node set corresponding to the target root node, and updating the first unit template file according to the first node types respectively corresponding to the multiple first child nodes included in the first child node set; S4, determining the first unit template file obtained by the update operation as the first unit template file, and determining multiple unit template files based on the first unit template file.

[0059] The target root node in S1 is the root node of the target structure file. It is determined whether the target root node has child nodes. If the target root node has no child nodes, the target data type set and / or abnormal information of the file to be parsed is prompted to facilitate the user to conduct targeted inspections. In S2, if the target root node has child nodes (such as Figure 4Node A shown has child node B), create a unit template file with only a root node (at this time, the unit template file corresponding to the root node is created, that is, the first unit template file), and name the root node of the first unit template file as the name of the root node of the unit template file; then obtain multiple first child nodes corresponding to the target root node, and update the first unit template file according to the first node type of each first child node, and determine the updated first unit template file as the first unit template file. The first node type is used to indicate whether the first child node is a leaf node. The update operation at this time is used to update the node attributes of the first unit template file, so as to facilitate the establishment of the association relationship between the first unit template file and other unit template files; then determine multiple unit template files based on the first unit template file. It should be noted that, for the convenience of description below, various unit template files will also be described as unit templates.

[0060] The above update operation can be understood, but not limited to, as a traversal of multiple first child nodes in the first child node set, specifically including: determining the first child node currently traversed as the first current child node, and determining the node type corresponding to the current first child node as the first current child node type, and when the first current child node type indicates that the first current child node is a leaf node, creating a first mapping child node under the root node of the first unit template file, and naming the node name of the first mapping child node as the node name of the first current child node (all indexes in this application can be understood, but not limited to, as indexes based on the node name of each node); when the first current child node type indicates that the first current child node is a non-leaf node, creating a first index child node under the root node of the first unit template file, and naming the node name of the first index child node as the node name of the first current child node, and storing the physical address of the first current child node in the address attribute corresponding to the first index child node. (The addresses described in the following statements can all be understood as physical addresses).

[0061] By performing an update operation on the first unit template file according to the node types of different child nodes under the root node of the target structure file, it is convenient to establish an association relationship between multiple unit template files.

[0062] As an optional implementation, the above-mentioned determination of multiple unit template files based on the first unit template file includes: S1, creating a target queue, and enqueuing the first unit template file at the end of the target queue; S2, judging whether the target queue is empty, and when the target queue is a non-empty queue, obtaining multiple head sub-nodes of the head unit template file, wherein the head unit template file is a unit template file located at the head of the target queue; S3, performing target operations on multiple head sub-nodes to obtain multiple unit template files; S4, controlling the head unit template file to exit the target queue.

[0063] The operation in S1 can be understood, but is not limited to, as creating an empty queue (the queue has the feature of first-in-first-out), and storing the first unit template file into the target queue. At this time, the first unit template file is the head unit template file of the target queue (also called the head unit template); the head sub-node in S2 can be understood, but is not limited to, as all index sub-nodes of the head unit template.

[0064] The operations in the above S3 specifically include: S3-1, determining any head child node among multiple head child nodes as the second child node; S3-2, creating a second unit template file corresponding to the second child node, and enqueuing the second unit template file at the end of the target queue; S3-3, obtaining the node name on the target structure file corresponding to the first address of the second child node, obtaining a reference name, and determining the name of the second root node as the reference name, wherein the second root node is the root node of the second unit template file; S3-4, modifying the first address of the second child node to the template address of the second unit template file, and determining the nodes among the multiple head child nodes other than the second child node that have not performed the target operation as the second child node.

[0065] The operation in the above S3 can be understood, but is not limited to, as traversing multiple head child nodes and performing corresponding operations during the traversal process. The second child node in the above S3-1 can be understood as the head child node currently traversed; the above first address is the physical address of the node stored in the address attribute of the second child node. In the above S3-4, after the first address of the second child node is modified to the template address of the second unit template file, it also includes obtaining the child node of the node corresponding to the reference name in the target structure file to obtain multiple reference second child nodes; performing a reference update operation on the second unit template file according to the node types corresponding to the multiple reference second child nodes; the reference update operation specifically includes: when the node type corresponding to the reference second child node indicates that the reference second child node is a leaf node, creating a second mapping child node under the root node of the second unit template, and naming the second mapping child node as the node name of the reference second child node; when the node type corresponding to the reference second child node indicates that the reference second child node is a non-leaf node, creating a second index child node under the root node of the second unit template, and naming the second index child node as the node name of the reference second child node, and storing the physical address of the reference second child node in the address attribute corresponding to the second index child node.

[0066] The following takes the target structure file shown in 4 as an example, combined with Figure 5 and Figure 6 ( Figure 6The Basket1 shown in the figure is the first unit template file, and the Basket2 is the second unit template file) The above S106 is described in detail. The above S106 specifically includes the following steps: S501, obtaining a target root node;

[0067] S502, determining whether the target root node has a child node, and if the target root node has a child node, executing S503, if the target root node does not have a child node, executing S504;

[0068] S503, prompting abnormal information;

[0069] S504, create a first unit template file (at this time, it can be understood that a unit template file corresponding to the target root node and only the root node is created, and after constructing the first mapping child node or the first index child node, the following can be obtained: Figure 6 Basket1 shown in Figure (a) of FIG. 1 , and name the node name of the first unit template file as the name of the target root node;

[0070] S505, obtaining a first child node set corresponding to the target root node;

[0071] S506, traversing the first child node set, specifically including: S506-1, determining any of the multiple first child nodes that have not been traversed as the current first child node; S506-2, judging whether the current first child node is a leaf node, and if the current first child node is a leaf node, executing S506-2-1, creating a first mapping child node under the root node of the first unit template, and determining the name of the first mapping child node as the name of the current first child node; if the current first child node is a leaf node, executing S506-2-2, creating a first index child node under the root node of the first unit template, and determining the name of the first index child node as the name of the current first child node, and storing the physical address of the current first child node in the address attribute corresponding to the first index child node; S506-3, judging whether there is an untraversed first child node among the multiple first child nodes, if so, executing S506-1, if not, executing S507;

[0072] S507, creating a target queue and adding the first unit template to the end of the target queue;

[0073] S508, determining whether the target queue is empty, if the target queue is empty, executing S518, if the target queue is not empty, executing S509;

[0074] S509, obtain and traverse multiple team head child nodes of the team head unit template file of the target queue, and determine any current team head child node that has not been traversed as the second child node; (the obtaining and determining in this step are two steps. In order to save diagram space, the two steps are combined into one step for explanation. When multiple team head child nodes have not been traversed, the step returned to this step is the determination step, that is, the step of determining any current team head child node that has not been traversed as the second child node).

[0075] S510, determine whether the second child node is an index child node, and if the second child node is an index child node, execute S511, if the second index child node is not an index child node, execute S516, the subsequent operation of S511 in the present application is for the index child node of the unit template file, so the head child node in the above S3-1 can be understood, but not limited to, as the index child node of the head unit template file obtained when obtaining, then the judgment operation in S510 can be omitted, but it can be understood that when obtaining the head child node above, the head child node is not limited to the index child node of the head unit template file, and the judgment in S501 cannot be omitted;

[0076] S511, create a second unit template file, and add the second unit template file to the end of the target queue (such as Figure 6 The first Basket2 shown in Figure (b);

[0077] S512, obtain a reference name, and name the root node name of the second unit template file as the reference name, and modify the first address of the second child node to the template address of the second unit template file (when the head unit template file is the first unit template file, this operation can be but is not limited to being understood as replacing the physical address of the current first child node stored in the address attribute corresponding to the first index child node in the first unit template file with the template address of the second unit template file, thereby completing the operation from Figure 6 Basket 1 as shown in FIG. (a) to Figure 6The correspondence of the first Basket2 shown in (b) of the figure can also be called mapping, and when the team head unit template file is the second unit template file, the address modification operation is similar to the above-mentioned specific modification operation, such as replacing the physical address of the node stored in the address attribute corresponding to the second index subnode of the first second unit template file with the template address of the second second unit template file, etc.), after replacing the node address with the address of the unit template file, the first index subnode name of the first unit template file can be called the first mapping subnode name. It can be understood that the first index subnode and the first mapping subnode are both subnodes under the root node of the unit template file. Here, for the convenience of description, the first or second index subnodes mentioned above and below are Each node represents a child node storing the physical address of the node. The first or second mapping child node described above and below represents a child node storing the physical address of the unit template file. During the traversal process, after the physical address of the node is replaced with the address of the unit template, the first or second index child node can be called the first or second mapping child node, so as to distinguish the child nodes storing different physical addresses in the subnode attributes. Usually, the physical address of the node stored in the target structure file is the same as the physical address of the same node in the file to be parsed, that is, each node corresponds to a unique physical address (the physical address corresponding to the same node is the same regardless of the node in any file), and different nodes correspond to different physical addresses.

[0078] S513, obtain and traverse multiple reference name child nodes of the node on the target structure file corresponding to the reference name (i.e., multiple child nodes of the node on the target structure file corresponding to the reference name), and determine any current reference name child node that has not been traversed as the current name child node; (the obtaining and determining in this step are two-step operations. In order to save diagram space, the two steps are combined into one step for explanation. When multiple reference name child nodes have not been traversed, the step returned to this step is the determination step, that is, the step of determining any current reference name child node that has not been traversed as the current name child node).

[0079] S514, determine whether the reference name child node is a leaf node, and if the reference name child node is a leaf node, execute S515-1, create a second mapping child node under the second unit template file, and name the second mapping child node as the name of the current child node; if the reference name child node is a non-leaf node, execute S515-2, create a second index child node under the root node of the second unit template file, name the second index child node as the name of the current child node, and store the physical address of the current child node in the address attribute corresponding to the second index child node;

[0080] S516, determining whether the traversal of multiple reference name child nodes has been completed, and if the traversal has been completed, executing S517, and if the traversal has not been completed, executing S513, determining any current untraversed reference name child node as the current name child node;

[0081] S517, determining whether the traversal of multiple head child nodes has been completed, if the traversal has been completed, executing S518, if the traversal has not been completed, executing S509, determining any currently untraversed head child node as the second child node;

[0082] S518, the head unit template file is dequeued, and then S508 is executed;

[0083] S519, obtain all unit template files.

[0084] After the above steps S501 to S519, the following can be obtained: Figure 4 The target structure file shown corresponds to Figure 6 The four unit template files shown in Figures (a), (b), (c), and (d) are as follows: Figure 6 Basket1 shown in Figure (a) is as follows Figure 4 The unit template file corresponding to the A node shown in the figure is mapped as follows Figure 6 The first Basket2 shown in Figure (b) is as follows: Figure 4 The unit template file corresponding to the B node shown in the figure is mapped as follows Figure 6 The second Basket2 shown in Figure (c) is as follows: Figure 4 The unit template file corresponding to the C node shown in the figure is mapped as follows Figure 6 The third Basket2 shown in Figure (d) is as follows: Figure 4 The unit template file corresponding to the F node shown in the figure stores the following in its mapping child node: Figure 4 The physical address of the K node is shown.

[0085] It should be noted that, in order to facilitate the subsequent target parsing operation, the specific node can be found from the file to be parsed, the sub-node in the above-mentioned unit template file can store the physical address of the corresponding node in the file to be parsed when storing the physical address of the node. If the physical address of the stored node in the target structure file can also accurately find the node during subsequent parsing, the physical address of the corresponding node in the target structure file can also be stored. This application does not make specific limitations on this.

[0086] Through the above-mentioned template operation in the present application, the target structure file can be split into multiple unit template files with only two layers of information structure, and the mapping of multiple unit template files is completed, which facilitates the accurate parsing of the required data when parsing the specific data corresponding to each node (also referred to as each data type) from the file to be parsed, while retaining the correspondence between multiple data.

[0087] As an optional implementation, the above-mentioned target parsing of the file to be parsed according to multiple unit template files to obtain a target data file also includes: S1, obtaining the root node names of multiple unit template files to obtain multiple unit root node names; S2, determining the unit template file corresponding to the unit root node name that matches the file root node name among the multiple unit root node names as the target unit template file; S3, performing a reference parsing operation on the file to be parsed according to the target unit template file to obtain a first data file; S4, determining the target data file according to the first data file.

[0088] The file root node name in S2 above can be understood, but not limited to, as the name of the root node of the file to be parsed. The operations in S1 to S2 can be understood, but not limited to, as determining the unit template file whose root node name corresponds to the root node name of the file to be parsed among multiple unit template files as the target unit template file; then, performing a reference parsing operation on the file to be parsed according to the target unit template file to obtain the first data file. The operations in S1 to S3 above can be understood, but not limited to, as performing data screening in the file to be parsed according to a single unit template file (such as the target unit template file), thereby obtaining data while ensuring the data structure (i.e., the correspondence between data and data). Then, the target data file can be determined according to the first data file.

[0089] The above S4 specifically includes: S4-1, obtaining multiple leaf nodes corresponding to the first data file; S4-2, when there is a preset leaf node that meets the preset attributes among the multiple leaf nodes, updating the attributes of the preset leaf node, and obtaining a leaf node template and a sub-file with the file node as the root node, wherein the leaf node template is a unit template file corresponding to the preset leaf node, and the file node is a node in the file to be parsed corresponding to the preset leaf node; S4-3, performing a reference parsing operation on the sub-file according to the leaf node template to obtain a second data file, and replacing the preset leaf node with the root node of the second data file; S4-4, when there is no preset leaf node that meets the preset attributes among the multiple leaf nodes, determining the first data file as the target data file.

[0090] Whether it meets the preset attribute can be understood as, but not limited to, whether the leaf node has the address attribute of the physical address of the storage node. If the leaf node has the address attribute of the physical address of the storage node, it is the case of meeting the preset attribute in S4-2 above, and the attribute of the preset leaf node is updated. If the leaf node does not have the address attribute of the physical address of the storage node, it is the case in S4-2 above, that is, the first data file is determined as the target data file; the above-mentioned updating of the attribute of the preset leaf node specifically includes: storing the address of the corresponding unit template file in the template attribute of the preset leaf node, and storing the physical address of the node corresponding to the preset leaf node (which can be understood as, but not limited to, the node with the same physical address as the preset leaf node) in the file to be parsed in the address attribute of the preset leaf node. Then, according to the leaf node template, the sub-file is subjected to a reference parsing operation to obtain a second data file, and the preset leaf node is replaced with the root node of the second data file (this operation can be understood as, but not limited to, determining the root node of the second data file as the preset leaf node, so as to achieve a mapping association between multiple data files (such as the first data file and the second data file)). It can be understood that the process of performing reference parsing operations on sub-files according to the leaf node template in the above S4-3 is essentially the same as the process of performing reference parsing operations on the file to be parsed according to the target unit template file. Therefore, when specifically understanding the above S4-3, the leaf node template in S4-3 can be replaced with the target unit template, and the sub-file in S4-3 can be replaced with the file to be parsed to understand the operation in the above S4-3.

[0091] The following Figure 7 Taking the example, the operations in S1 to S4 are described in detail, including:

[0092] S701, a file to be parsed and multiple unit template files obtained;

[0093] S702, determining a unit template file whose root node name is consistent with the root node name of the file to be parsed from among multiple unit template files, and setting it as the target unit template file;

[0094] S703, performing a reference parsing operation on the file to be parsed according to the target unit template file to obtain a first data file;

[0095] S704, determining whether there is a leaf node that meets the preset attribute in the first data file, and if there is a leaf node that meets the preset attribute in the first data file, executing S705, and if there is no leaf node that meets the preset attribute in the first data file, executing S710;

[0096] S705, marking the leaf nodes that meet the preset attributes as preset leaf nodes;

[0097] S706, updating the attribute value of the template attribute of the preset leaf node to the physical address of the corresponding unit template, and updating the attribute value of the address attribute of the preset leaf node to the physical address of the node on the corresponding file to be parsed;

[0098] S707, obtaining a leaf node template and a sub-file with the file node as the root node, wherein the leaf node template is a unit template file corresponding to a preset leaf node, and the file node is a node in the to-be-parsed file corresponding to the preset leaf node;

[0099] S708, performing a reference parsing operation on the sub-file according to the leaf node template to obtain a second data file;

[0100] S709, replacing the preset leaf node with the root node of the second data file (which may be understood as, but not limited to, hanging the second data file on the first data file to complete the update of the first data file, thereby realizing the mapping association between multiple data files);

[0101] S710, obtaining a target data file (the target data file may be understood as, but not limited to, a tree structure file represented in the form of a tree diagram).

[0102] The operations in S1 to S4 above may be understood, but are not limited to, as extracting data from the to-be-parsed file according to multiple target data files, and retaining the original data correspondence between the parsed data and the to-be-parsed file.

[0103] Through the above implementation of the present application, a target data file including required data can be accurately obtained, while retaining the original data correspondence between the required data in the file to be parsed, thereby avoiding data confusion.

[0104] As an optional implementation, the above-mentioned reference parsing operation is performed on the file to be parsed according to the target unit template file to obtain the first data file, including: S1, creating a first reference data file; S2, obtaining the node in the file to be parsed corresponding to the root node of the target unit template file, obtaining the first reference node, and determining the name of the first reference data file as the name of the first reference node; S3, obtaining the reference root node of the target unit template file and multiple reference sub-nodes in the target unit template file; S4, determining the first data file according to the reference root node, the multiple reference sub-nodes, the file to be parsed and the first reference data file.

[0105] The operation in S1 above can be understood, but not limited to, as creating a tree structure file with only a root node corresponding to the target unit template file, that is, the first reference data file mentioned above. The acquisition operation in S2 can be understood, but not limited to, as first acquiring the root node of the target unit template file; determining the node physical address of the root node from the root node of the target unit template file; finding the corresponding node in the file to be parsed according to the node physical address, and the found node is the first reference node. Then, determining the name of the first reference data file as the name of the first reference node can be understood, but not limited to, as determining the name of the root node of the first reference data file as the name of the first reference node (that is, it can be understood, but not limited to, as a query of the first reference data file). ); then obtain the root node of the target unit template file (i.e. the reference root node mentioned above) and multiple reference child nodes in the target unit template file (from the above specific description, it can be seen that each unit template file can have two types of child nodes, one is a child node that stores the physical address of the node, i.e. the first or second index child node mentioned above, and the other is a child node that stores the physical address of another unit template file, which is convenient for finding another unit template file from one unit template file, i.e. the first or second mapping child node mentioned above); the reference root node can be but not limited to be understood as the root node of the target unit template file, and the multiple reference child nodes can be but not limited to be understood as child nodes under the root node of the target unit template file.

[0106] Through the above-mentioned implementation mode of the present application, data corresponding to the target unit template file can be searched from the file to be parsed according to the target unit template file, and the correspondence between the target unit template file and the nodes in the file to be parsed and other target unit template files can be retained, thereby ensuring that the data subsequently found maintains its original relationship.

[0107] As an optional implementation, the above-mentioned determining the first data file based on the reference root node, multiple reference sub-nodes, the file to be parsed and the first reference data file includes: S1, determining multiple index paths based on the reference root node and the multiple reference sub-nodes; S2, determining multiple third sub-nodes from the file to be parsed based on the multiple index paths, wherein each index path corresponds to a third sub-node; S3, updating the first reference data file based on the second node types and multiple third sub-nodes corresponding to each of the multiple reference sub-nodes, and determining the updated first reference data file as the first data file.

[0108] The multiple index paths in the above S1 can be but are not limited to being understood as at least one index path. Since the process of performing reference parsing operations on the file to be parsed according to the target unit template file is substantially the same as the reference parsing operations on the sub-files according to the leaf node template, this description is adopted. The operations in the above S1 can be but are not limited to being understood as determining multiple index paths from the file to be parsed according to the reference root node and multiple reference sub-nodes. For example, assuming that the target structure file is as follows Figure 4 The target structure file shown in the figure is as follows: Figure 6 Figure (a) to Figure 6 The target unit template file in S1 is as follows: Figure 6 As shown in Basket1 in (a) of FIG. 1 , the reference root node is node A in Basket1. Then the at least one index path (i.e., the multiple index paths) determined based on the reference root node and the multiple reference child nodes can be understood as determining the index path from the to-be-parsed file based on node A and its child node named B, whose address attribute stores the address of the first Basket2. Then, the determined index paths are A→B1 and A→B2, where B1 is as follows: Figure 2 The first B node from left to right under the A node shown is B2. Figure 2 The second B node from the left to the right under the A node shown is shown; according to this index path, multiple third child nodes can be determined in the file to be parsed (these multiple third child nodes can also be understood as at least one third child node).

[0109] Through the above-mentioned implementation mode of the present application, a first reference data file corresponding to the target unit template file can be created according to the target unit template file and the file to be parsed, and then the final first data file is obtained by updating the first reference data file, thereby ensuring the original data structure of the parsed data in the file to be parsed.

[0110] As an optional implementation, the above-mentioned updating operation on the first reference data file according to the second node type and multiple third sub-nodes corresponding to each of the multiple reference sub-nodes includes: S1, when the second node type indicates that the reference sub-node is a non-leaf node, creating multiple address sub-nodes for the first reference data file according to the multiple third sub-nodes, and respectively constructing address attributes and template attributes for the multiple address sub-nodes, wherein each address sub-node corresponds to a third sub-node; S2, storing the third sub-node address corresponding to the address attribute in the address attribute, and storing the address of the reference sub-node in the template attribute, wherein the third sub-node address is the address of the third sub-node corresponding to the address sub-node; S3, when the second node type indicates that the reference sub-node is a leaf node, creating multiple data sub-nodes for the first reference data file according to the multiple third sub-nodes, and storing the data corresponding to the multiple third sub-nodes in the multiple data sub-nodes, wherein each data sub-node corresponds to a third sub-node.

[0111] The storage of address attributes in the above S2 can be but is not limited to being understood as storing the address of the third child node corresponding to the address child node in the attribute value of the address attribute, and the storage of template attributes can be but is not limited to being understood as storing the address of the reference child node in the attribute value of the template attribute. The address of the reference child node and the address of the third child node can both be but are not limited to being understood as the physical address of the node; the operations in the above S1 to S3 can be but are not limited to being understood as first creating a first data file corresponding to the target unit template file based on the target unit template file and the file to be parsed, and then performing a reference parsing operation on the sub-file based on the leaf node template according to the above process; creating second data files corresponding to multiple unit template files respectively; and finally mounting multiple second data files on the first data file according to the process of replacing the node with the unit template address in the data extraction process, that is, establishing a file association relationship between the first data file and the multiple second data files, thereby obtaining the final first data file.

[0112] Assume the target structure file is as follows Figure 4 The target structure file shown in the figure, the multiple unit template files obtained are as follows Figure 6 Figure (a) to Figure 6 The unit template file shown in Figure (d) in the following example is used to perform a reference analysis operation on the target unit template file. Figure 8 The above reference parsing operation is described in detail, and the reference parsing operation specifically includes:

[0113] S801, target unit template file to be parsed file (when the reference parsing operation is performed on the sub-file according to the leaf node template, S801 refers to the leaf node template and the file to be parsed);

[0114] S802, creating a first reference data file having only a root node;

[0115] S803, obtaining a reference root node of the target unit template file, and finding a first reference node corresponding to the reference root node in the file to be parsed according to the reference root node;

[0116] S804, naming the first reference data file as the name of the first reference node;

[0117] S805, traversing the child nodes of the target unit template file (i.e., the reference child nodes mentioned above), and determining any child node that has not been traversed as the current target child node;

[0118] S806, finding multiple third child nodes on the file to be parsed according to the index composed of the reference root node and the current target child node;

[0119] S807, determine whether the current target child node is a leaf node, and if the current target child node is a leaf node, execute S808-1, if the current target child node is not a leaf node, execute S808-2;

[0120] S808-1, creating multiple data sub-nodes under the root node of the first reference unit template file, and storing data corresponding to multiple third sub-nodes in the multiple data sub-nodes respectively, wherein each third sub-node corresponds to one data sub-node;

[0121] S808-2, creating multiple address sub-nodes under the root node of the first reference unit template file, and constructing address attributes and template attributes for the multiple address sub-nodes respectively, storing the address of the third sub-node corresponding to the address sub-node in the attribute value of the address attribute, and storing the address of the reference sub-node in the attribute value of the template attribute;

[0122] S809, determining whether the traversal of the child nodes of the target unit template file has been completed. If the traversal has not been completed, executing S805 to determine any child node that has not been traversed as the current target child node. If the traversal has been completed, executing S810;

[0123] S810, obtaining a first reference data file corresponding to a target unit template file.

[0124] The storage operation in the above S808 - 2 may be understood, but is not limited to, as storing in the address attribute.

[0125] It can be understood that the reference parsing operation (such as Figure 8The above S801 to S810 shown in the figure can obtain the first data file corresponding to the target unit template file, and by performing a reference parsing operation on the sub-file according to the leaf node template (i.e. replacing the target unit template file in the above S801 to S810 with the leaf node template, and determining the file to be parsed as the sub-file), the second data file corresponding to the leaf node template can be obtained, thereby obtaining the data file corresponding to each unit template file.

[0126] Assume that multiple unit template files are as follows Figure 6 Figure (a) to Figure 6 The four unit template files shown in Figure (d) in the figure can be used to obtain the data files corresponding to the four unit template files, and then the following can be performed based on the multiple data files: Figure 7 The operations in S705 to 706 shown in the figure can update the physical address of the node stored in the template attribute corresponding to the child node of the root node in the data file to the physical address of the unit template file corresponding to the data file (such as Fig. 9 FIG. (a) shows that the first data file corresponding to the target unit template file is obtained after the physical address of the stored node is updated to the physical address of the unit template file corresponding to the first reference data file corresponding to the target unit template file. Figure 7 S707 to S709 shown in the figure implement mounting multiple second data files onto the first data file, such as Fig. 9 The intermediate data file shown in Figure (b) is obtained by mounting the first data file corresponding to the unit template file corresponding to node A and the second data files corresponding to the unit template files corresponding to multiple nodes B. After the mounting is completed, the following can be obtained: Figure 7 The target data file in S710 is as follows: Fig.10 The target data file finally obtained is shown in this figure (this figure is a target data type set, that is, the data requirement is {E, D, K}, and the file to be parsed is as follows Figure 2 The tree structure file shown in the figure is used as an example to make the file, and each node stores the data content stored in the corresponding node in the file to be parsed). The node names are combined with English letters and numbers to facilitate understanding. Figure 2 Which nodes in the file to be parsed are shown, for example, node A1 represents Figure 2 The A node and B1 node shown in the figure are as follows Figure 2 The first B node from left to right is shown in the figure. The B2 node represents Figure 2 The second B node from left to right as shown; E1 represents Figure 2 As shown in the figure, the E node under the first B node from left to right, E2 represents Figure 2The E node under the second B node from the left to the right is shown...

[0127] With data requirements {E, D, K}, the file to be parsed is as follows Figure 2 As an example, for ease of understanding, the above-mentioned file parsing method of the present application can be understood, but not limited to, as needing to be Figure 2 The file parsing method shown in the figure parses all E nodes, D nodes and K nodes from all nodes of the file to be parsed, and retains the original position relationship of all E nodes, D nodes and K nodes in the file to be parsed.

[0128] Through the above-mentioned implementation mode of the present application, the required data can be identified from the file to be parsed, and the original data structure of the data in the file to be parsed (that is, the correspondence between the data) can be retained, and the changes in the specific structure of the data stored in multiple nodes in the file to be parsed are not restricted, thereby improving the flexibility of the file parsing method and broadening the scope of application of the file parsing method.

[0129] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.

[0130] According to another aspect of an embodiment of the present invention, a file parsing device for implementing the above-mentioned file parsing method is also provided.

[0131] According to another aspect of an embodiment of the present invention, there is also provided an electronic device for implementing the above-mentioned file parsing method, and the electronic device may be a terminal device or a server. This embodiment is illustrated by taking the electronic device as a terminal device as an example. The electronic device includes: at least one processor; and a memory connected to the at least one processor in communication; wherein the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor performs the steps in any one of the above-mentioned method embodiments. Optionally, in this embodiment, the above-mentioned electronic device may be located in at least one network device among a plurality of network devices of a computer network. The above-mentioned processor may be configured to execute the above-mentioned file parsing method through a computer program.

[0132] Alternatively, a person skilled in the art can understand that the structure described above is for illustration only, and the electronic device may also be a terminal device such as a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, and a mobile Internet device (Mobile Internet Devices, MID), PAD, etc. The above description does not limit the structure of the above electronic device. For example, the electronic device may also include more or fewer components (such as a network interface, etc.) than described, or have a configuration different from that described.

[0133] Among them, the memory can be used to store software programs and modules, such as program instructions / modules corresponding to the file parsing method in the embodiment of the present invention. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, realizing the above-mentioned file parsing method. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof. Among them, the memory can be specifically used, but not limited to, for storing various data involved in the above-mentioned file parsing method. The above-mentioned electronic device is used to implement the above-mentioned file parsing method.

[0134] Optionally, the transmission device is used to receive or send data via a network. Specific examples of the network may include wired networks and wireless networks. In one example, the transmission device includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices and routers via a network cable so as to communicate with the Internet or a local area network. In one example, the transmission device is a radio frequency (Radio Frequency, RF) module, which is used to communicate with the Internet wirelessly. In addition, the electronic device also includes: a display and a connection bus, which is used to connect the various module components in the electronic device.

[0135] According to one aspect of the present application, a computer-readable storage medium is provided, and a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above-mentioned file parsing method.

[0136] Those skilled in the art will appreciate that the implementation of all or part of the processes in the above method embodiments can be accomplished by instructing related hardware through a computer program. The program can be stored in a computer-readable storage medium. When the program is executed, it can include processes such as those in the above method embodiments.

[0137] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A file parsing method, characterized in that: include: Acquire a file to be parsed and a target data type set, wherein the file to be parsed includes a reference data set and multiple reference data types corresponding to the reference data set, the target data type set includes multiple target data types, and the target data sets corresponding to the multiple target data types are subsets of the reference data set; Performing a structural operation on the target data type set according to the file to be parsed to obtain a target structure file, wherein the structural operation is used to convert the target data type set into a tree structure file; Performing a template operation on the target structure file to obtain a plurality of unit template files, wherein the template operation is used to split the structure information in the target structure file into a plurality of files that meet a preset structure; The file to be parsed is subjected to target parsing according to the multiple unit template files to obtain a target data file, wherein the target data file includes multiple target data types, the target data set, and the corresponding relationship between the target data corresponding to the multiple target data types in the file to be parsed.

2. The method according to claim 1, characterized in that The target structure file is templated to obtain multiple unit template files, including: Determine whether the target root node has a child node, and if the target root node has no child node, prompt abnormal information, wherein the target root node is the root node of the target structure file, and the abnormal information is used to indicate that the target data type set and / or the file to be parsed is abnormal; In the case that the target root node has child nodes, creating a first unit template file, and determining the name of the first root node as the name of the target root node, wherein the first root node is the root node of the first unit template file; Acquire a first child node set corresponding to the target root node, and perform an update operation on the first unit template file according to first node types respectively corresponding to a plurality of first child nodes included in the first child node set; A first unit template file obtained by performing the updating operation is determined as the first unit template file, and a plurality of the unit template files are determined based on the first unit template file.

3. The method according to claim 2, characterized in that Determining a plurality of the unit template files according to the first unit template file includes: Create a target queue, and add the first unit template file to the end of the target queue; Determine whether the target queue is empty, and if the target queue is a non-empty queue, obtain multiple head subnodes of the head unit template file, wherein the head unit template file is a unit template file located at the head of the target queue; Performing a target operation on the plurality of team head sub-nodes to obtain a plurality of the unit template files; Control the head unit template file to exit the target queue.

4. The method according to claim 3, characterized in that Performing target operations on the plurality of team head sub-nodes to obtain a plurality of the unit template files includes: Determine any one of the plurality of team head sub-nodes as the second sub-node; Creating a second unit template file corresponding to the second child node, and adding the second unit template file to the tail of the target queue; Acquire a node name on the target structure file corresponding to the first address of the second child node to obtain a reference name, and determine the name of the second root node as the reference name, wherein the second root node is the root node of the second unit template file; The first address of the second subnode is modified to be the template address of the second unit template file, and the nodes among the plurality of head subnodes other than the second subnode that have not been subjected to the target operation are determined as the second subnode.

5. The method according to claim 1, characterized in that The target data file is parsed according to the plurality of unit template files to obtain a target data file, further comprising: Acquire root node names of multiple unit template files to obtain multiple unit root node names; Determine the unit template file corresponding to the unit root node name matching the file root node name among the plurality of unit root node names as the target unit template file; Performing a reference parsing operation on the file to be parsed according to the target unit template file to obtain a first data file; The target data file is determined according to the first data file.

6. The method according to claim 5, characterized in that Determining the target data file according to the first data file includes: Obtain multiple leaf nodes corresponding to the first data file; In the case that there is a preset leaf node that meets the preset attributes among the multiple leaf nodes, the attributes of the preset leaf node are updated, and a leaf node template and a subfile with the file node as the root node are obtained, wherein the leaf node template is a unit template file corresponding to the preset leaf node, and the file node is a node in the file to be parsed corresponding to the preset leaf node; Perform the reference parsing operation on the subfile according to the leaf node template to obtain a second data file, and replace the preset leaf node with the root node of the second data file; When there is no preset leaf node that meets the preset attribute among the multiple leaf nodes, the first data file is determined as the target data file.

7. The method according to claim 5, characterized in that Performing a reference parsing operation on the file to be parsed according to the target unit template file to obtain the first data file includes: creating a first reference data file; Acquire a node in the to-be-parsed file corresponding to a root node of the target unit template file to obtain a first reference node, and determine the name of the first reference data file as the name of the first reference node; Acquire a reference root node of the target unit template file and a plurality of reference child nodes in the target unit template file; The first data file is determined according to the reference root node, the plurality of reference child nodes, the file to be parsed, and the first reference data file.

8. The method according to claim 7, characterized in that Determining the first data file according to the reference root node, the plurality of reference child nodes, the file to be parsed, and the first reference data file includes: Determine a plurality of index paths according to the reference root node and the plurality of reference child nodes; Determine a plurality of third sub-nodes from the to-be-parsed file according to the plurality of index paths, wherein each index path corresponds to a third sub-node; An update operation is performed on the first reference data file according to the second node types corresponding to each of the plurality of reference sub-nodes and the plurality of third sub-nodes, and the updated first reference data file is determined as the first data file.

9. The method according to claim 8, characterized in that Performing an updating operation on the first reference data file according to the second node types corresponding to the plurality of reference sub-nodes and the plurality of third sub-nodes, including: In the case where the second node type indicates that the reference subnode is a non-leaf node, creating multiple address subnodes for the first reference data file according to the multiple third subnodes, and constructing address attributes and template attributes for the multiple address subnodes respectively, wherein each address subnode corresponds to one third subnode; Storing the third subnode address corresponding to the address attribute in the address attribute, and storing the address of the reference subnode in the template attribute, wherein the third subnode address is the address of the third subnode corresponding to the address subnode; When the second node type indicates that the reference subnode is a leaf node, multiple data subnodes are created for the first reference data file based on the multiple third subnodes, and the data corresponding to the multiple third subnodes are stored in the multiple data subnodes respectively, wherein each data subnode corresponds to a third subnode.

10. The method according to claim 1, characterized in that According to the file to be parsed, a structured operation is performed on the target data type set to obtain a target structured file, including: Creating a reference structure file, and determining the root node name of the reference structure file as the root node name of the file to be parsed; Determine the index lengths corresponding to the plurality of target data types according to a preset data set, wherein the preset data set includes a plurality of preset data types and a corresponding relationship between each of the preset data types, and the plurality of preset data types include a plurality of target data types; Creating a child node under the root node of the reference structure file according to the file to be parsed and the index length corresponding to each of the target data types; The obtained reference structure file is determined as the target structure file.