Transaction log file parsing method and device, terminal equipment and storage medium
Patent Information
- Application Number
- CN202310476058.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-25
- Publication Date
- 2026-10-27
- Estimated Expiration
- 2043-04-25
AI Technical Summary
[0005]本申请的主要目的在于提供一种交易流水文件解析方法、装置、终端设备及存储介质,旨在解决如何快速、准确地解析不同银行的交易流水文件的问题
[0042]本申请提出的交易流水文件解析方法、装置、终端设备及存储介质。通过文本解析工具,将交易流水文件解析为若干行数据,并从所述若干行数据中提取关键字及对应的行号;将所述关键字及对应的行号,与预先配置的不同银行的交易流水的解析模板依次进行匹配,确定所述交易流水文件对应的解析模板,并获取交易流水信息;对所述交易流水文件进行格式化处理;根据所述交易流水信息和格式化处理后的交易流水文件,解析得到交易流水明细并展示。基于本申请,通过将交易流水文件与不同银行的交易流水模板进行匹配,确定存储模板类型,从而获取到对应的交易流水信息,并对交易流水文件进行格式化处理,从而得到交易流水明细,达到了方便、快捷、准确地解析不同银行的交易流水文件的效果。
Smart Images

Figure CN116432627B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of file parsing, and more particularly to methods, apparatus, terminal devices, and storage media for parsing transaction log files. Background Technology
[0002] Transaction records are detailed statements of transactions made by bank accounts or payment institution accounts. Each bank or payment institution provides proof of customer transaction records, and the generated electronic transaction record files typically include information such as the bank or payment institution, account name, account number, and a list of transaction details. To quickly and conveniently obtain this information, a unified method for parsing transaction record files is needed.
[0003] One existing method for parsing transaction records is to use OCR technology to quickly scan the transaction document and obtain relevant information. However, OCR technology is easily affected by factors such as image brightness, font size, and color, resulting in low accuracy of the parsed information. Another method is to use PDF to HTML conversion technology to extract relevant information from the transaction document. However, PDF to HTML conversion is easily affected by table presentation and text formatting, resulting in significant differences between the converted HTML and the original table, thus limiting its coverage.
[0004] Therefore, how to quickly and accurately parse transaction records from different banks is an urgent problem to be solved. Summary of the Invention
[0005] The main purpose of this application is to provide a method, apparatus, terminal device and storage medium for parsing transaction records, aiming to solve the problem of how to quickly and accurately parse transaction records from different banks.
[0006] To achieve the above objectives, this application provides a method for parsing transaction log files, which is applied in the field of file parsing technology. The method for parsing transaction log files includes the following steps:
[0007] The transaction log file is parsed into several lines of data using a text parsing tool, and keywords and corresponding line numbers are extracted from the several lines of data.
[0008] The keywords and their corresponding line numbers are matched sequentially with the pre-configured parsing templates for transaction records from different banks to determine the parsing template corresponding to the transaction record file and obtain the transaction record information.
[0009] The transaction log file is formatted.
[0010] Based on the transaction flow information and the formatted transaction flow file, the transaction flow details are obtained through parsing.
[0011] Optionally, the parsing template includes at least transaction key, account key, and card number key. The step of sequentially matching the key and its corresponding line number with pre-configured parsing templates for transaction records from different banks to determine the parsing template corresponding to the transaction record file and obtain transaction record information includes:
[0012] The parsing template is traversed, and the serial keywords in the parsing template are matched sequentially with the keywords and their corresponding line numbers to obtain the first matching result;
[0013] If the first matching result is successful, then obtain the account keywords and card number keywords of the successfully matched parsed template;
[0014] The account keywords of the successfully matched parsed template are matched with the keywords and their corresponding row numbers to obtain a second matching result;
[0015] If the second matching result is successful, then based on the account keyword of the successfully matched parsed template, extract the account string from the keyword and the corresponding line number and remove spaces;
[0016] The card number keyword of the successfully matched parsed template is matched with the keyword and the corresponding line number to obtain the third matching result;
[0017] If the third matching result is successful, then based on the card number keyword of the successfully matched parsed template, the card number string is extracted from the keyword and the corresponding line number and spaces are removed.
[0018] Optionally, the step of formatting the transaction log file includes:
[0019] Obtain the corresponding parsed row data of the table from the aforementioned rows of data;
[0020] Establish a two-dimensional coordinate system based on the parsed row data;
[0021] The rows of the parsed row data are formatted according to the two-dimensional coordinate system.
[0022] Based on the two-dimensional coordinate system, format the table cells of the parsed row data;
[0023] The header of the parsed row data is formatted according to the two-dimensional coordinate system.
[0024] Optionally, the step of formatting the rows of the parsed row data according to the two-dimensional coordinate system includes:
[0025] Iterate through the rows of the parsed data in sequence;
[0026] When the horizontal and vertical coordinates of the parsed row data in the two-dimensional coordinate system meet the preset line break conditions, the row data is processed for line break formatting.
[0027] Optionally, the step of formatting the table cells of the parsed row data according to the two-dimensional coordinate system includes:
[0028] Iterate through the table cells in the parsed row data in sequence;
[0029] When the horizontal and vertical coordinates of adjacent cells in the two-dimensional coordinate system meet the preset merging conditions, the adjacent table cells and their corresponding elements are processed by table cell merging format.
[0030] Optionally, the step of formatting the header of the parsed row data according to the two-dimensional coordinate system includes:
[0031] Iterate through the coordinates of the elements in the parsed row data in sequence;
[0032] If the coordinates of the element and the coordinates of the table header meet the preset coordinate change conditions, then change the coordinates of the element and the coordinates of the table header.
[0033] Optionally, the step of formatting the table unit processing the parsed row data according to the two-dimensional coordinate system further includes:
[0034] Parse the header of the row data from the parsed row data.
[0035] This application also proposes a transaction log file parsing device, which includes:
[0036] The extraction module is used to parse the transaction log file into several lines of data using a text parsing tool, and extract keywords and corresponding line numbers from the several lines of data;
[0037] The storage module is used to match the keywords and corresponding line numbers with the pre-configured parsing templates of transaction records from different banks in sequence, determine the parsing template corresponding to the transaction record file, and obtain the transaction record information.
[0038] The format module is used to format the transaction log file;
[0039] The display module is used to parse the transaction details based on the transaction information and the formatted transaction file, and then display them.
[0040] This application also proposes a terminal device, which includes a memory, a processor, and a transaction log file parsing program stored in the memory and executable on the processor. When the transaction log file parsing program is executed by the processor, it implements the steps of the transaction log file parsing method.
[0041] This application also proposes a storage medium storing a transaction log file parsing program, wherein the transaction log file parsing program, when executed by a processor, implements the steps of the transaction log file parsing method.
[0042] This application proposes a method, apparatus, terminal device, and storage medium for parsing transaction transaction files. Using a text parsing tool, the transaction transaction file is parsed into several lines of data, and keywords and corresponding line numbers are extracted from these lines. These keywords and line numbers are then matched sequentially with pre-configured parsing templates for different banks' transaction transaction files to determine the corresponding parsing template and obtain the transaction transaction information. The transaction transaction file is then formatted. Based on the transaction transaction information and the formatted transaction transaction file, the transaction transaction details are parsed and displayed. Based on this application, by matching the transaction transaction file with transaction transaction templates from different banks to determine the storage template type, the corresponding transaction transaction information is obtained, and the transaction transaction file is formatted to obtain the transaction transaction details, achieving the effect of convenient, fast, and accurate parsing of transaction transaction files from different banks. Attached Figure Description
[0043] Figure 1 This is a schematic diagram of the functional modules of the terminal equipment to which the transaction log file parsing device of this application belongs;
[0044] Figure 2 This is a flowchart illustrating a first exemplary embodiment of the transaction log file parsing method of this application;
[0045] Figure 3 This is a flowchart illustrating a second exemplary embodiment of the transaction log file parsing method of this application;
[0046] Figure 4 This is a flowchart illustrating a third exemplary embodiment of the transaction log file parsing method of this application.
[0047] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0048] It should be understood that the specific implementation examples described herein are merely for illustrative purposes and are not intended to limit the scope of this application.
[0049] The main solution of this application embodiment is to send parsing templates of transaction records from different banks to a database for storage; use a text parsing tool to parse the transaction record file into several lines of data, and extract keywords and corresponding line numbers from the several lines of data; match the keywords and corresponding line numbers with pre-configured parsing templates of transaction records from different banks in sequence to determine the parsing template corresponding to the transaction record file and obtain the transaction record information; format the transaction record file; and parse the transaction record details based on the transaction record information and the formatted transaction record file to obtain and display the transaction record details. Based on this solution, by matching the transaction record file with transaction record templates from different banks to determine the storage template type, the corresponding transaction record information is obtained, and the transaction record file is formatted to obtain and display the transaction record details, achieving the effect of convenient, fast, and accurate parsing of transaction record files from different banks.
[0050] Specifically, refer to Figure 1 , Figure 1 This is a schematic diagram of the functional modules of the terminal device to which the transaction record file parsing device of this application belongs. The transaction record file parsing device is a terminal device capable of parsing transaction record files to obtain transaction record details, and it can be implemented on the terminal device in the form of hardware or software.
[0051] In this embodiment, the terminal device to which the transaction log file parsing device belongs includes at least an output module 110, a processor 120, a memory 130, and a communication module 140.
[0052] The memory 130 stores the operating system and a transaction record file parsing program. The transaction record file parsing device can send parsing templates for transaction records from different banks to a database for storage. Using a text parsing tool, the transaction record file is parsed into several lines of data, and keywords and corresponding line numbers are extracted from these lines. The keywords and corresponding line numbers are then matched sequentially with pre-configured parsing templates for transaction records from different banks to determine the corresponding parsing template for the transaction record file and obtain the transaction record information. The transaction record file is then formatted. Based on the transaction record information and the formatted transaction record file, the transaction record details are parsed and displayed, and stored in the memory 130. The output module 110 can be a display screen, etc. The communication module 140 can include a WIFI module, a mobile communication module, and a Bluetooth module, etc., and communicates with external devices or servers through the communication module 140.
[0053] The transaction log file parsing program in memory 130, when executed by the processor, performs the following steps:
[0054] Send the parsed templates of transaction records from different banks to the database for storage;
[0055] The transaction log file is parsed into several lines of data using a text parsing tool, and keywords and corresponding line numbers are extracted from the several lines of data.
[0056] The keywords and their corresponding line numbers are matched sequentially with the pre-configured parsing templates for transaction records from different banks to determine the parsing template corresponding to the transaction record file and obtain the transaction record information.
[0057] The transaction log file is formatted.
[0058] Based on the transaction flow information and the formatted transaction flow file, the transaction flow details are obtained through parsing.
[0059] Furthermore, when the transaction log file parsing program in memory 130 is executed by the processor, it also performs the following steps:
[0060] The parsing template is traversed, and the serial keywords in the parsing template are matched sequentially with the keywords and their corresponding line numbers to obtain the first matching result;
[0061] If the first matching result is successful, then obtain the account keywords and card number keywords of the successfully matched parsed template;
[0062] The account keywords of the successfully matched parsed template are matched with the keywords and their corresponding row numbers to obtain a second matching result;
[0063] If the second matching result is successful, then based on the account keyword of the successfully matched parsed template, extract the account string from the keyword and the corresponding line number and remove spaces;
[0064] The card number keyword of the successfully matched parsed template is matched with the keyword and the corresponding line number to obtain the third matching result;
[0065] If the third matching result is successful, then based on the card number keyword of the successfully matched parsed template, the card number string is extracted from the keyword and the corresponding line number and spaces are removed.
[0066] Furthermore, when the transaction log file parsing program in memory 130 is executed by the processor, it also performs the following steps:
[0067] Obtain the corresponding parsed row data of the table from the aforementioned rows of data;
[0068] Establish a two-dimensional coordinate system based on the parsed row data;
[0069] The rows of the parsed row data are formatted according to the two-dimensional coordinate system.
[0070] Based on the two-dimensional coordinate system, format the table cells of the parsed row data;
[0071] The header of the parsed row data is formatted according to the two-dimensional coordinate system.
[0072] Furthermore, when the transaction log file parsing program in memory 130 is executed by the processor, it also performs the following steps:
[0073] Iterate through the rows of the parsed data in sequence;
[0074] When the horizontal and vertical coordinates of the parsed row data in the two-dimensional coordinate system meet the preset line break conditions, the row data is processed for line break formatting.
[0075] Furthermore, when the transaction log file parsing program in memory 130 is executed by the processor, it also performs the following steps:
[0076] Iterate through the table cells in the parsed row data in sequence;
[0077] When the horizontal and vertical coordinates of adjacent cells in the two-dimensional coordinate system meet the preset merging conditions, the adjacent table cells and their corresponding elements are processed by table cell merging format.
[0078] Furthermore, when the transaction log file parsing program in memory 130 is executed by the processor, it also performs the following steps:
[0079] Iterate through the coordinates of the elements in the parsed row data in sequence;
[0080] If the coordinates of the element and the coordinates of the table header meet the preset coordinate change conditions, then change the coordinates of the element and the coordinates of the table header.
[0081] Furthermore, when the transaction log file parsing program in memory 130 is executed by the processor, it also performs the following steps:
[0082] Parse the header of the row data from the parsed row data.
[0083] Based on, but not limited to, the terminal device architecture described above, this application proposes method embodiments.
[0084] Reference Figure 2 , Figure 2 This is a flowchart illustrating a first exemplary embodiment of the transaction log file parsing method. The transaction log file parsing method includes:
[0085] Step S110: Send the parsed templates of transaction records from different banks to the database for storage;
[0086] Specifically, the parsing template for any bank's transaction records, stored in the database, includes at least a template name, transaction record keywords, account keywords, card number keywords, and a parsing method name. The template name represents the bank's name, and the transaction record keywords, account keywords, and card number keywords are lists containing dictionary elements. Specifically, the dictionary keys for elements in the transaction record keywords list are the line number and the keyword; the dictionary keys for elements in the account keywords list are the line number, the start keyword (startKeyword), and the end keyword (endKeyword); and the dictionary keys for elements in the card number keywords list are the line number, the start keyword (startKeyword), and the end keyword (endKeyword). Developers organize the rules using transaction record files from various banks and save them to the database.
[0087] Step S120: Using a text parsing tool, the transaction log file is parsed into several lines of data, and keywords and corresponding line numbers are extracted from the several lines of data;
[0088] Specifically, the text parsing tools include, but are not limited to, Spire or PDFbox, which parse all text on the current page and convert transaction log files into row data. In a two-dimensional coordinate system, there are horizontal and vertical axes. If the difference in the horizontal axis of any row is less than -5 times the font height, and the difference in the y-axis is greater than the font height; or, the difference in the x-axis is less than -5 times the font height, and the difference in the y-axis is less than -1 times the font height; or, the difference in the x-axis is greater than 2 times the font height, and the difference in the y-axis is greater than 3 times the font height; or, the y-axis is negative and intersects with the previous element; or, an element intersects with two elements, but the two elements do not intersect with each other, then that element is discarded. Elements are represented as follows: (left, right, upper, lower, cell, fontSize); where left, right, upper, and lower represent the left, right, top, and bottom positions of the text, respectively; cell represents the text content; and fontSize represents the font size.
[0089] Step S130: Match the keywords and corresponding line numbers with the pre-configured parsing templates for transaction records of different banks in sequence to determine the parsing template corresponding to the transaction record file and obtain the transaction record information;
[0090] Specifically, the transaction record parsing templates for different banks include the template name, transaction record file keywords, account keywords, card number keywords, and parsing method name. The transaction record parsing templates for different banks are obtained from the database. The keywords and corresponding line numbers are matched with the keywords in the transaction file parsing templates of multiple different banks. If a match is successful, the successfully matched transaction file parsing template is confirmed as the parsing template corresponding to the current transaction file. Based on the keywords provided by the confirmed transaction file parsing template, transaction information is obtained, including account keywords and card number keywords in the parsing template corresponding to the transaction file. The account keywords in the parsing template corresponding to the transaction file are matched with the keywords and corresponding line numbers to obtain a second successful match result. The second successful match result includes the account start keyword and account end keyword. The string between the second successful match result and the corresponding line number is extracted from the keywords and removed spaces to represent the account. The card number keywords in the parsing template corresponding to the transaction file are matched with the keywords and corresponding line numbers to obtain a third successful match result. The third successful match result includes the card number start keyword and card number end keyword. The string between the third successful match result and the corresponding line number is extracted from the keywords and removed spaces to represent the card number. If a match fails, the system will match the parsing template of the next bank's transaction record until a parsing template corresponding to the transaction record file can be identified.
[0091] Step S140: Format the transaction log file;
[0092] Specifically, the formatting of the transaction log file parsing file includes formatting the header, rows, and table cells. The specific parsing method involves: obtaining the corresponding parsed row data from the several rows of data; establishing a two-dimensional coordinate system based on the parsed row data; formatting the rows of the parsed row data according to the two-dimensional coordinate system; formatting the table cells of the parsed row data according to the two-dimensional coordinate system; and formatting the header of the parsed row data according to the two-dimensional coordinate system.
[0093] Step S150: Based on the transaction flow information and the formatted transaction flow file, parse the transaction flow details and display them.
[0094] Specifically, the table content is parsed into a map structure using the table header. The table header is used as the key, and the corresponding table cell is used as the value. The table cells of each row of data are traversed sequentially to obtain the structured transaction log data, which is then output and displayed. The structured transaction log data is shown below, where record1...recordN represent the serial number of each parsed row, and the key and value are the value of the row data corresponding to the serial number and the corresponding table header element, respectively.
[0095] {record1:[{key1:value1},{key2:value2}]};
[0096] {record2:[{key2:value2},{key3:value3}]};
[0097] {recordN:[{keyN:valueN},{keyN+1:valueN+1}]}.
[0098] This embodiment, through the above-described scheme, specifically involves sending parsing templates of transaction records from different banks to a database for storage; using a text parsing tool, the transaction record file is parsed into several lines of data, and keywords and corresponding line numbers are extracted from these lines; the keywords and corresponding line numbers are then matched sequentially with pre-configured parsing templates of transaction records from different banks to determine the parsing template corresponding to the transaction record file and obtain the transaction record information; the transaction record file is then formatted; and based on the transaction record information and the formatted transaction record file, the transaction record details are parsed and displayed. Based on this scheme, by matching the transaction record file with transaction record templates from different banks to determine the storage template type, the corresponding transaction record information is obtained, and the transaction record file is formatted to obtain and display the transaction record details. This achieves the effect of convenient, fast, and accurate parsing of transaction record files from different banks.
[0099] Furthermore, referring to Figure 3 , Figure 3 This is a flowchart illustrating a second exemplary embodiment of the transaction record file parsing method. The parsing template includes at least transaction record keywords, account keywords, and card number keywords. The step of sequentially matching the keywords and their corresponding bank numbers with pre-configured transaction record parsing templates from different banks to determine the parsing template corresponding to the transaction record file and obtain transaction record information includes:
[0100] Step S1301: Traverse the parsing template and match the serial keywords in the parsing template with the keywords and their corresponding line numbers in turn to obtain the first matching result;
[0101] Specifically, the value of the transaction key in the parsed template is a list structure containing multiple dictionary elements. The dictionary elements have a line number (`line`) and a keyword (`keyword`). The line number corresponds to the line containing the keyword, and the keyword value can be a bank name, account number, account holder name, or other account-related information. The keywords and line numbers extracted from the transaction file are matched against the transaction key in the parsed template. If a match is found, it means that this matching template is applicable to the currently parsed transaction file.
[0102] Step S1302: If the first matching result is successful, then obtain the account keyword and card number keyword of the successfully matched parsing template;
[0103] Specifically, the first matching result is successful, meaning that the keywords of the current transaction file are successfully matched with the transaction keywords of the parsing template. This allows us to determine the parsing template corresponding to the successfully matched transaction file, and then parse the current transaction file using the parsing template corresponding to the transaction file, thus ensuring the accuracy and usability of the template.
[0104] Step S1303: Match the account keywords of the successfully matched parsed template with the keywords and corresponding row numbers to obtain a second matching result;
[0105] Specifically, the account keywords in the parsing template corresponding to the transaction log file are stored in dictionary form. The account keywords include information such as the account start keyword, account end keyword, and line number. The current keyword and its corresponding line number are matched with the keys and values in the dictionary of account keywords to obtain a successful match result and the corresponding line number. If the match is unsuccessful, the process jumps to S1301, and the transaction keywords in the parsing template are matched sequentially with the keyword and its corresponding line number to obtain the first match result for matching the next parsing template.
[0106] Step S1304: If the second matching result is successful, then according to the account keyword of the successfully matched parsed template, extract the account string from the keyword and the corresponding line number and remove spaces;
[0107] Specifically, the second successful match result is used as the account start keyword and account end keyword. Therefore, by extracting the string between the second successful match result from the keyword and the corresponding line number, the account string can be obtained. By removing spaces from the account string, the account number of the transaction record file can be obtained. If the match fails, the process jumps to S1301, and the transaction keywords in the parsing template are matched sequentially with the keyword and the corresponding line number to obtain the first match result for matching the next parsing template.
[0108] Step S1305: Match the card number keyword of the successfully matched parsed template with the keyword and the corresponding row number to obtain the third matching result;
[0109] Specifically, the card number keywords in the parsing template corresponding to the transaction log file are stored in a dictionary. The card number keywords include the card number start keyword, the card number end keyword, and the corresponding line number. The current keyword and the corresponding line number are matched with the keys and values in the dictionary of card number keywords to obtain a successful match result and the corresponding line number. If the match is unsuccessful, the process jumps to S1301, and the transaction log keywords in the parsing template are matched sequentially with the keyword and the corresponding line number to obtain the first match result for matching the next parsing template.
[0110] Step S1306: If the third matching result is successful, then according to the card number keyword of the successfully matched parsed template, extract the card number string from the keyword and the corresponding line number and remove spaces.
[0111] Specifically, the third successful match result serves as the card number start keyword and card number end keyword. Therefore, by extracting the string between the third successful match result from the keyword and the corresponding line number, the card number string can be obtained. By removing spaces from the card number string, the card number of the transaction record file is obtained. If the match fails, the process jumps to S1301, and the transaction record keywords in the parsing template are matched sequentially with the keyword and the corresponding line number to obtain the first match result for matching the next parsing template.
[0112] This embodiment, through the above-described scheme, specifically traverses the parsing template and sequentially matches the transaction keywords in the parsing template with the keywords and their corresponding line numbers to obtain a first matching result. If the first matching result is successful, the account keyword and card number keyword of the successfully matched parsing template are obtained. The account keyword of the successfully matched parsing template is then matched with the keywords and their corresponding line numbers to obtain a second matching result. If the second matching result is successful, the account string is extracted from the keywords and their corresponding line numbers and spaces are removed. The card number keyword of the successfully matched parsing template is then matched with the keywords and their corresponding line numbers to obtain a third matching result. If the third matching result is successful, the card number string is extracted from the keywords and their corresponding line numbers and spaces are removed. Based on this scheme, the card number and account of the transaction transaction are obtained, achieving the effect of accurately extracting transaction transaction-related information from the transaction transaction file.
[0113] Furthermore, refer to Figure 4 , Figure 4 This is a flowchart illustrating a third exemplary embodiment of the transaction log file parsing method. The step of formatting the transaction log file includes:
[0114] Step S1501: Obtain the parsed row data corresponding to the table from the plurality of rows of data;
[0115] Specifically, the transaction log file is parsed into rows of data by using file parsing tools such as Spire or PDFbox to parse all the text on the page.
[0116] Step S1502: Establish a two-dimensional coordinate system based on the parsed row data;
[0117] Specifically, a two-dimensional coordinate system is established based on the parsed row data. This system includes an X-axis and a Y-axis. The elements in the row data are located in table cells, which include top, bottom, left, and right positions. Each element can be represented as (left, right, upper, lower, cell, fontSize). Here, left, right, upper, and lower represent the left, right, top, and bottom positions of the table cell on the x-axis and y-axis, respectively. Cell represents the text content within the table cell, and fontSize represents the font size of the text.
[0118] Step S1503: Format the rows of the parsed row data according to the two-dimensional coordinate system;
[0119] Specifically, in a two-dimensional coordinate system, the line break condition for row data is as follows: if the x-axis difference is less than -5 times the font height and the y-axis difference is greater than the font height; or, the x-axis difference is less than -5 times the font height and the y-axis difference is less than -1 times the font height; or, the x-axis difference is greater than 2 times the font height and the y-axis difference is greater than 3 times the font height; or, the y-axis is negative and intersects with the previous element; or, if an element intersects with two other elements but there is no intersection between the two elements, then that element is removed.
[0120] Step S1504: Format the table cells of the parsed row data according to the two-dimensional coordinate system;
[0121] Specifically, the system iterates through the cells in each row of data. Cells are merged only if they intersect on the horizontal axis and differ on the vertical axis. If the fonts differ, the previous data is deleted, and only the content with the smaller font is retained. The criteria for merging cells include: merging cell content (i.e., concatenating the cell values of the two elements); processing the x-axis interval (taking the union of the (left, right) values of the two elements as the new value); and processing the y-axis interval (taking the union of the (upper, lower) values of the two elements as the new value).
[0122] Step S1505: Format the header of the parsed row data according to the two-dimensional coordinate system.
[0123] Specifically, each parsing method defines a date and amount data dictionary, and processes data iteratively row by row. If a row contains both a date and an amount uniquely, the table header is parsed. Parsing table rows: Iteratively process each cell row by row. If a cell intersects the x-axis of multiple header elements, remove them; extract the row data of cells that uniquely intersect the x-axis of the amount and date headers, where the cells intersecting the amount header contain only numbers, and the cells intersecting the date header begin with a number. Refining the header coordinates: Traverse the table row data, processing as follows: Determine if the elements in the row intersect the x-axis of the header row; if the coordinates intersect, expand the coordinate range, taking the smallest left and largest right, and update the left and right of the corresponding header element; obtain elements that do not intersect with the header; obtain headers that do not intersect with the elements; compare the positions of the unmatched headers with the cell data, comparing the distances between the cell and the header's four coordinate points (left, right, and right), obtaining the header with the smallest distance, and updating the left and right of the corresponding header element.
[0124] This application, through the above-described scheme, specifically involves obtaining the parsed row data corresponding to the table from the plurality of rows of data; establishing a two-dimensional coordinate system based on the parsed row data; formatting the rows of the parsed row data according to the two-dimensional coordinate system; formatting the table cells of the parsed row data according to the two-dimensional coordinate system; and formatting the table header of the parsed row data according to the two-dimensional coordinate system.
[0125] Based on this scheme, the row data is formatted using a coordinate system, which facilitates the generation of detailed flow data.
[0126] Furthermore, this application also proposes a transaction log file parsing device, which includes:
[0127] The storage module is used to send the parsed templates of transaction records from different banks to the database for storage;
[0128] The parsing module is used to parse the transaction log file into several lines of data using a text parsing tool, and extract keywords and corresponding line numbers from the several lines of data;
[0129] The matching module is used to match the keywords and corresponding line numbers with the pre-configured parsing templates of transaction records from different banks in sequence, determine the parsing template corresponding to the transaction record file, and obtain the transaction record information.
[0130] The format module is used to format the transaction log file;
[0131] The output module is used to parse the transaction details based on the transaction information and the formatted transaction file.
[0132] Furthermore, this application also proposes a terminal device, which includes a memory, a processor, and a transaction log file parsing program stored in the memory and executable on the processor. When the transaction log file parsing program is executed by the processor, it implements the steps of the transaction log file parsing method.
[0133] Since the transaction log file parsing program adopts all the technical solutions of all the aforementioned embodiments when it is executed by the processor, it has at least all the beneficial effects brought about by all the technical solutions of all the aforementioned embodiments, which will not be repeated here.
[0134] Furthermore, this application also proposes a readable storage medium storing a program, wherein the transaction log file parsing program, when executed by a processor, implements the steps of the transaction log file parsing method described above.
[0135] Since the transaction log file parsing program adopts all the technical solutions of all the aforementioned embodiments when it is executed by the processor, it has at least all the beneficial effects brought about by all the technical solutions of all the aforementioned embodiments, which will not be repeated here.
[0136] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0137] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0138] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, controlled terminal, or network device, etc.) to execute the methods of each embodiment of this application.
[0139] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. A method for parsing transaction log files, characterized in that, The method for parsing transaction log files includes the following steps: The transaction log file is parsed into several lines of data using a text parsing tool, and keywords and corresponding line numbers are extracted from the several lines of data. The keywords and their corresponding line numbers are matched sequentially with the pre-configured parsing templates for transaction records from different banks to determine the parsing template corresponding to the transaction record file and obtain the transaction record information. The parsing template includes at least transaction key, account key, and card number key. The step of matching the key and its corresponding line number with pre-configured parsing templates for transaction records from different banks to determine the parsing template corresponding to the transaction record file and obtain transaction record information includes: The parsing template is traversed, and the serial keywords in the parsing template are matched sequentially with the keywords and their corresponding line numbers to obtain the first matching result; If the first matching result is successful, then obtain the account keywords and card number keywords of the successfully matched parsed template; The account keywords of the successfully matched parsed template are matched with the keywords and their corresponding row numbers to obtain a second matching result; If the second matching result is successful, then based on the account keyword of the successfully matched parsed template, extract the account string from the keyword and the corresponding line number and remove spaces; The card number keyword of the successfully matched parsed template is matched with the keyword and the corresponding line number to obtain the third matching result; If the third matching result is successful, then based on the card number keyword of the successfully matched parsed template, extract the card number string from the keyword and the corresponding line number and remove spaces; The transaction log file is formatted. The step of formatting the transaction log file includes: Obtain the corresponding parsed row data of the table from the aforementioned rows of data; Establish a two-dimensional coordinate system based on the parsed row data; The rows of the parsed row data are formatted according to the two-dimensional coordinate system. Based on the two-dimensional coordinate system, format the table cells of the parsed row data; The header of the parsed row data is formatted according to the two-dimensional coordinate system. Based on the transaction flow information and the formatted transaction flow file, the transaction flow details are obtained through parsing.
2. The transaction log file parsing method according to claim 1, characterized in that, The step of formatting the rows of the parsed row data according to the two-dimensional coordinate system includes: Iterate through the rows of the parsed data in sequence; When the horizontal and vertical coordinates of the parsed row data in the two-dimensional coordinate system meet the preset line break conditions, the row data is processed for line break formatting.
3. The transaction log file parsing method according to claim 1, characterized in that, The step of formatting the table unit of the parsed row data according to the two-dimensional coordinate system includes: Iterate through the table cells in the parsed row data in sequence; When the horizontal and vertical coordinates of adjacent cells in the two-dimensional coordinate system meet the preset merging conditions, the adjacent table cells and their corresponding elements are processed by table cell merging format.
4. The transaction log file parsing method according to claim 1, characterized in that, The The steps for formatting the header of the parsed row data according to the two-dimensional coordinate system include: Iterate through the coordinates of the elements in the parsed row data in sequence; If the coordinates of the element and the coordinates of the table header meet the preset coordinate change conditions, then change the coordinates of the element and the coordinates of the table header.
5. The transaction log file parsing method according to claim 1, characterized in that, Before the step of formatting the table unit of the parsed row data according to the two-dimensional coordinate system, the method further includes: Parse the header of the row data from the parsed row data.
6. A transaction log file parsing device, characterized in that, The transaction log file parsing device includes: The extraction module is used to parse the transaction log file into several lines of data using a text parsing tool, and extract keywords and corresponding line numbers from the several lines of data; The storage module is used to match the keywords and corresponding line numbers with the pre-configured parsing templates of transaction records from different banks in sequence, determine the parsing template corresponding to the transaction record file, and obtain the transaction record information. The parsing template includes at least transaction keywords, account keywords, and card number keywords. The saving module is also used to traverse the parsing template and match the transaction keywords in the parsing template with the keywords and their corresponding line numbers in sequence to obtain a first matching result. If the first matching result is successful, then obtain the account keywords and card number keywords of the successfully matched parsed template; The account keywords of the successfully matched parsed template are matched with the keywords and their corresponding row numbers to obtain a second matching result; If the second matching result is successful, then based on the account keyword of the successfully matched parsed template, extract the account string from the keyword and the corresponding line number and remove spaces; The card number keyword of the successfully matched parsed template is matched with the keyword and the corresponding line number to obtain the third matching result; If the third matching result is successful, then based on the card number keyword of the successfully matched parsed template, extract the card number string from the keyword and the corresponding line number and remove spaces; The format module is used to format the transaction log file; The format module is also used to obtain the parsed row data corresponding to the table from the plurality of rows of data; Establish a two-dimensional coordinate system based on the parsed row data; The rows of the parsed row data are formatted according to the two-dimensional coordinate system. Based on the two-dimensional coordinate system, format the table cells of the parsed row data; The header of the parsed row data is formatted according to the two-dimensional coordinate system. The display module is used to parse the transaction details based on the transaction information and the formatted transaction file.
7. A terminal device, characterized in that, The terminal device includes a memory, a processor, and a transaction log file parsing program stored in the memory and executable on the processor. When the transaction log file parsing program is executed by the processor, it implements the steps of the transaction log file parsing method as described in any one of claims 1-5.
8. A storage medium, characterized in that, The storage medium stores a transaction log file parsing program, which, when executed by a processor, implements the steps of the transaction log file parsing method as described in any one of claims 1-5.
Citation Information
Patent Citations
Method, device, computer device and storage medium for managing pipeline data
CN109255108A
Method and device for mining PDF table in PDF file and medium
CN114201620A