Terminal block splicing method and system based on XML parsing

Through the terminal strip splicing method based on XML parsing, the terminal strip information is automatically processed, and the problems of inefficient splicing and numbering and error-prone in the prior art are solved, and efficient and accurate terminal strip information processing is achieved.

CN118643660BActive Publication Date: 2025-02-25NANJING FIVE MINING WISDOM ELECTRIC POWER TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410775099.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-17
Publication Date
2025-02-25
Estimated Expiration
2044-06-17

AI Technical Summary

Technical Problem

In the prior art, the splicing and numbering of terminal strips requires manual operation, which is inefficient and prone to errors, and lacks an automated processing method.

Method used

Using the terminal strip splicing method based on XML parsing, the terminal strip information is automatically processed through the steps of data reading and preprocessing, data filtering and sorting, data splicing and deduplication, and result generation, and the processing results are output to the Excel table.

Benefits of technology

Automatic splicing and numbering of terminal strips is realized, working efficiency and accuracy are improved, and manual intervention is reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118643660B_ABST
    Figure CN118643660B_ABST
Patent Text Reader

Abstract

The present invention discloses a terminal strip splicing method and system based on XML parsing, the method comprising the following steps: data reading and preprocessing: reading an XML file from a specified path, and parsing the terminal strip information therein, including the terminal strip icon and text content; data filtering and sorting: filtering and sorting the terminal strip information, obtaining only the terminal strip name and the terminal strip number, and sorting by size; data splicing and deduplication: splicing the terminal strip information in different XML files, and deduplication by a recursive algorithm to ensure that the spliced ​​terminal strip information is non-repetitive; result generation: outputting the processed terminal strip information to an Excel table to generate the final splicing result. The method can automatically process the splicing and numbering of terminal strips, and improve work efficiency and accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer vision and image processing, and in particular to a terminal block splicing method and system based on XML parsing. Background Art

[0002] In the field of electrical engineering and automation, terminal blocks are a common electrical connector used to connect cables and equipment. With the advancement of digitalization and intelligence, the management and operation and maintenance of terminal block equipment are also becoming more intelligent. However, the most critical link in this process is to identify terminal block information through computer vision. Due to the long size of terminal blocks, conventional shooting methods cannot fully obtain all the information of terminal blocks, so multiple terminal blocks need to be shot multiple times before splicing. Traditional terminal block splicing methods are inefficient and prone to errors. In the prior art, terminal block splicing and numbering are performed manually, which is labor-intensive and error-prone. Therefore, an automated terminal block splicing method is needed to improve efficiency and accuracy. Summary of the invention

[0003] The technical problem to be solved by the present invention is how to provide a terminal block splicing method and system based on XML parsing which can automatically process the splicing and numbering of terminal blocks and improve the work efficiency and accuracy.

[0004] In order to solve the above technical problems, the technical solution adopted by the present invention is: a terminal block splicing method based on XML parsing, comprising the following steps:

[0005] Data reading and preprocessing: Read the XML file from the specified path and parse the terminal strip information, including the terminal strip icon and text content;

[0006] Data filtering and sorting: filter and sort terminal strip information, obtain only terminal strip name and terminal strip number, and sort by size;

[0007] Data splicing and deduplication: splice the terminal strip information in different XML files and use a recursive algorithm to remove duplicates to ensure that there is no duplication in the spliced ​​terminal strip information;

[0008] Result generation: used to output the processed terminal strip information to an Excel table to generate the final splicing result.

[0009] Correspondingly, the embodiment of the present invention further discloses a terminal block splicing system based on XML parsing, comprising:

[0010] Data reading and preprocessing module: used to read XML files from the specified path and parse the terminal strip information, including terminal strip icons and text content;

[0011] Data filtering and sorting module: used to filter and sort terminal block information, obtain only the terminal block name and terminal block number, and sort by size;

[0012] Data splicing and deduplication module: used to splice the terminal strip information in different XML files and remove duplicates through a recursive algorithm to ensure that there is no duplication in the spliced ​​terminal strip information;

[0013] Result generation module: used to output the processed terminal strip information to an Excel table to generate the final splicing result.

[0014] The beneficial effect of adopting the above technical solution is that the method and system of the present invention can automatically process the splicing and numbering of terminal blocks, thereby improving work efficiency and accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] The present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments.

[0016] Figure 1 is a flowchart of the method described in an embodiment of the present invention

[0017] Figure 2 The terminal block information diagram provided by the present invention;

[0018] Figure 3 This is the final effect diagram of the terminal block information splicing provided by the present invention.

[0019] Figure 4 It is a principle block diagram of the system described in the embodiment of the present invention. DETAILED DESCRIPTION

[0020] The following is a clear and complete description of the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0021] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.

[0022] like Figure 1 As shown, an embodiment of the present invention discloses a terminal block splicing method based on XML parsing, comprising the following steps:

[0023] 1) Data reading and preprocessing: Read the XML file from the specified path and parse the terminal strip information, including icons and text content.

[0024] First, the present invention reads the terminal row data stored in the XML file from the specified path, such as Figure 2 As shown, these XML files contain information about the terminal strip, including icons and text content. By parsing the nodes in the XML file, this information can be extracted and stored in the memory for subsequent processing. Specifically, the method will traverse all XML files under the specified path, and for each file, use the XML parsing library to parse the file content, find the node containing the terminal strip information (such as the "icons" and "texts" subnodes under the "content" node), and extract the icon and text data, which are stored in the Data_icons and Data_texts dictionaries respectively.

[0025] 1-1) File reading

[0026] First, you need to read multiple XML files. Each XML file contains multiple levels of node information, including root nodes, child nodes, icons, and text data. Use the ElementTree library to parse the XML files and extract the required data.

[0027] 1-2) Data analysis

[0028] Extract necessary attributes and child node information from the root node. Parse icons and texts nodes, store each icon and corresponding text information in a dictionary or list. Further process the icon attributes for subsequent filtering and sorting.

[0029] 2) Data filtering and sorting: Filter and sort the terminal strip information, obtain only the terminal strip inscription and terminal strip number, and sort by size. After data preprocessing, the method needs to filter and sort the data. The purpose of the filtering step is to retain only the information related to the terminal strip, such as the terminal strip inscription (Terminal_inscription) and the terminal strip number (Terminal_number) from the extracted icon data. The method retains only these specific types of icons by specifying filtering conditions. Next, the filtered icon data is sorted by its size to ensure that the terminal strip information can be correctly spliced ​​during subsequent processing. The basis for sorting is the size of the icon, which is arranged from small to large for subsequent splicing operations.

[0030] 2-1) Filter conditions

[0031] Based on the icon name (IconName), only icons of certain types are retained, such as "Terminal_inscription" and "Terminal_number" (terminal number).

[0032] D×C→D'whereC

[0033] ={IconName

[0034] ∈{'Terminal_inscription','Terminal_number'}}

[0035] 2-2) Dimension calculation

[0036] Calculate the size of the icon (Sizer) for subsequent sorting. Assuming that the coordinate information of the icon is stored in a string, you need to parse the string and calculate the minimum size.

[0037] Sizer(xy)=min({xy 1 ,xy 3 ,xy 5 ,xy 7})

[0038] 2-3) Sorting algorithm

[0039] Sort icons by size, making sure smaller icons come first.

[0040] sort(D',key=Sizer)→D"

[0041] 3) Data splicing and deduplication: The terminal strip information in different XML files is spliced ​​and deduplicated through a recursive algorithm to ensure that there is no duplication in the spliced ​​terminal strip information.

[0042] In this process, the method splices the terminal strip information in different XML files to generate a complete terminal strip data set. In the splicing process, the problem of data duplication needs to be solved. To this end, the present invention adopts a recursive algorithm to detect and delete duplicate data. Specifically, the subscripts of the terminal strip inscriptions that are not repeated in the current file and the previous file are first found, and then the terminal strip information in different files is compared by a recursive algorithm, and the duplicate entries are marked and deleted, so as to ensure that the terminal strip information after the final splicing is non-duplicate and complete.

[0043] 3-1) Data splicing

[0044] The data of multiple files are stitched together in a specific order. The data of the first file is processed first, and then the data of other files are added in sequence. During the stitching process, it is necessary to check whether the data is repeated and remove the repeated data.

[0045] 3-2) Deduplication Algorithm

[0046] A recursive algorithm is used to check for the same type of icon and text information in both datasets, and if duplicates are found, the index is updated and the duplicate data is skipped.

[0047] A∪B→C and C-duplicates(C)→C'

[0048] 4) Excel result generation: Output the processed terminal strip information to an Excel table to generate the final splicing result.

[0049] Finally, the processed terminal strip information is output to an Excel table to generate the final splicing result. When generating an Excel table, the system will fill the terminal strip information into the table according to a specific format and beautify the table, for example, setting the cell alignment and border style. Specifically, the method will traverse the processed terminal strip data, fill each piece of information into the corresponding cell of the Excel table by column, and set the center alignment and border style for each cell to ensure that the generated Excel table is neat and beautiful. Finally, the system saves the generated Excel file to the specified path for users to view and use, such as Figure 3 shown.

[0050] 4-1) Create an Excel file

[0051] Use the openpyxl library to create a new Excel workbook and get the default worksheet, setting the cell style, including alignment and border style.

[0052] 4-2) Data writing

[0053] Write the processed data into an Excel table and fill in specific columns and rows according to the icon type and the corresponding text information. If the icon is "Terminal_inscription", merge the cells and fill in the corresponding text. If the icon is "Terminal_number", fill in the corresponding cells with relevant information according to its left and right connection relationship.

[0054] 4-3) Save the file

[0055] The generated Excel file is saved to the specified path. The file name contains the current date and time for easy identification and management.

[0056] like Figure 4 As shown, corresponding to the method, the embodiment of the present invention further discloses a terminal block splicing system based on XML parsing, which is characterized by comprising:

[0057] Data reading and preprocessing module 101: used to read the XML file from the specified path and parse the terminal strip information therein, including the terminal strip icon and text content;

[0058] Data filtering and sorting module 102: used to filter and sort the terminal block information, obtain only the terminal block name and terminal block number, and sort by size;

[0059] Data splicing and deduplication module 103: used to splice the terminal strip information in different XML files and remove duplicates through a recursive algorithm to ensure that the spliced ​​terminal strip information has no duplication;

[0060] Result generation module 104: used to output the processed terminal row information into an Excel table to generate the final splicing result.

[0061] Furthermore, the data reading and preprocessing module 101 includes:

[0062] 1) File reading unit 1011: used to first read a number of XML files, each XML file includes multiple levels of node information, including root nodes, child nodes, icons and text data, use ElementTree library to parse the XML files, and extract the required data;

[0063] 2) Data parsing unit 1012: used to extract necessary attributes and child node information from the root node, parse icons and texts nodes, store each icon and corresponding text information in a dictionary or list, and further process the icon attributes for subsequent filtering and sorting.

[0064] Furthermore, the data filtering and sorting module 102 includes:

[0065] 1) Filter condition unit 1021: used to retain only icons of a specific type according to the names of the icons;

[0066] 2) Size calculation unit 1022: calculates the size of the icon for subsequent sorting; assuming that the coordinate information of the icon is stored in a string, it is necessary to parse the string and calculate the minimum size;

[0067] 3) Sorting algorithm unit 1023: used to sort icons according to their sizes, ensuring that smaller icons are placed at the front.

[0068] Furthermore, the data splicing and deduplication module 103 includes:

[0069] 1) Data splicing unit 1031: used to splice data of multiple files together in a specific order; first process the data of the first file, and then add the data of other files in sequence; during the splicing process, it is necessary to check whether the data is repeated and remove the repeated data;

[0070] 2) De-duplication algorithm unit 1032: used to use a recursive algorithm to check the same type of icons and text information in two data sets. If duplicate items are found, the index is updated and the duplicate data is skipped.

[0071] The result generation module 104 includes:

[0072] 1) Excel file creation unit 1041: used to create a new Excel workbook using the openpyxl library and obtain the default worksheet; set the cell style, including alignment and border style;

[0073] 2) a data writing unit 1042, used to write the processed data into an Excel table, filling specific columns and rows according to the type of icon and the corresponding text information;

[0074] 3) File saving unit 1043, used to save the generated Excel file to a specified path, with the file name containing the current date and time for easy distinction and management.

[0075] Through the above method and system, the present invention can efficiently and accurately complete the splicing and numbering of terminal blocks, reduce manual intervention, and improve work efficiency and accuracy.

[0076] Each embodiment in this specification focuses on the differences from other embodiments, and the same or similar parts between the embodiments can be referred to each other. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0077] The principles and implementation methods of the present invention are described in this article using specific examples. The description of the above embodiments is only used to help understand the method and core idea of ​​the present invention. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.

Claims

1. A terminal block splicing method based on XML parsing, characterized in that The steps include: Data reading and preprocessing: Read the XML file from the specified path and parse the terminal strip information, including the terminal strip icon and text content; Data filtering and sorting: filter and sort terminal strip information, obtain only terminal strip name and terminal strip number, and sort by size; Data splicing and deduplication: splice the terminal strip information in different XML files and use a recursive algorithm to remove duplicates to ensure that there is no duplication in the spliced ​​terminal strip information; Result generation: used to output the processed terminal strip information to an Excel table to generate the final splicing result; The data filtering and sorting includes the following steps: 1) Filter conditions: Keep only icons of a specific type, based on their names; 2) Size calculation: Calculate the size of the icon for subsequent sorting; suppose the coordinate information of the icon is stored in a string, and you need to parse the string and calculate the minimum size; 3) Sorting algorithm: Sort icons by size, making sure smaller icons come first.

2. The terminal block splicing method based on XML parsing according to claim 1, characterized in that: The data reading and preprocessing includes the following steps: 1) File reading: First, read several XML files. Each XML file includes multiple levels of node information, including root nodes, child nodes, icons, and text data. Use the ElementTree library to parse the XML files and extract the required data. 2) Data analysis: Extract necessary attributes and child node information from the root node, parse the icons and texts nodes, store each icon and the corresponding text information in a dictionary or list, and further process the icon attributes for subsequent filtering and sorting.

3. The terminal block splicing method based on XML parsing according to claim 1, characterized in that: The method for data splicing and deduplication comprises the following steps: 1) Data splicing: Combine the data of multiple files in a specific order; first process the data of the first file, and then add the data of other files in sequence; during the concatenation process, check whether the data is repeated and remove the repeated data; 2) Deduplication algorithm A recursive algorithm is used to check for the same type of icon and text information in both datasets, and if duplicates are found, the index is updated and the duplicate data is skipped.

4. The terminal block splicing method based on XML parsing according to claim 1, characterized in that: The result generation comprises the following steps: 1) Create an Excel file: Use the openpyxl library to create a new Excel workbook and get the default worksheet; set the cell style, including alignment and border style; 2) Data writing: Write the processed data into an Excel table and fill specific columns and rows according to the type of icon and the corresponding text information; 3) Save the file: The generated Excel file is saved to the specified path. The file name contains the current date and time for easy identification and management.

5. A terminal block splicing system based on XML parsing, characterized in that include: Data reading and preprocessing module: used to read XML files from the specified path and parse the terminal strip information, including terminal strip icons and text content; Data filtering and sorting module: used to filter and sort terminal block information, obtain only the terminal block name and terminal block number, and sort by size; Data splicing and deduplication module: used to splice the terminal strip information in different XML files and remove duplicates through a recursive algorithm to ensure that there is no duplication in the spliced ​​terminal strip information; Result generation module: used to output the processed terminal block information to an Excel table to generate the final splicing result; The data filtering and sorting module includes: 1) Filter condition unit: used to retain only icons of a specific type according to the icon name; 2) Size calculation unit: calculates the size of the icon for subsequent sorting; assumes that the coordinate information of the icon is stored in a string, and needs to parse the string and calculate the minimum size; 3) Sorting algorithm unit: used to sort icons according to their sizes, ensuring that smaller icons are placed at the front.

6. The terminal block splicing system based on XML parsing as claimed in claim 5, characterized in that: The data reading and preprocessing module includes: 1) File reading unit: used to first read several XML files, each XML file includes multiple levels of node information, including root nodes, child nodes, icons and text data, use ElementTree library to parse the XML files, and extract the required data; 2) Data parsing unit: used to extract necessary attributes and child node information from the root node, parse icons and texts nodes, store each icon and corresponding text information in a dictionary or list, and further process the icon attributes for subsequent filtering and sorting.

7. The terminal block splicing system based on XML parsing as claimed in claim 5, characterized in that: The data splicing and deduplication module includes: 1) Data splicing unit: used to splice data from multiple files together in a specific order; first process the data of the first file, and then add the data of other files in sequence; during the splicing process, it is necessary to check whether the data is repeated and remove the repeated data; 2) De-duplication algorithm unit: used to check the same type of icons and text information in two data sets using a recursive algorithm. If duplicates are found, the index is updated and the duplicate data is skipped.

8. The terminal block splicing system based on XML parsing as claimed in claim 5, characterized in that: The result generation module comprises: 1) Excel file creation unit: used to create a new Excel workbook using the openpyxl library and obtain the default worksheet; set the cell style, including alignment and border style; 2) a data writing unit, used to write the processed data into an Excel table, filling specific columns and rows according to the type of icon and the corresponding text information; 3) File saving unit, used to save the generated Excel file to a specified path, with the file name containing the current date and time for easy distinction and management.

Citation Information

Patent Citations

  • Table file analysis method and device thereof

    CN113505580A

  • Scientific and technical literature table extraction method based on XML

    CN115935910A