File processing method, device, electronic device and storage medium
By identifying the file type, determining the parsing strategy and storing file information, the problem of data management systems in the prior art requiring frequent modification of background programs is solved, and the flexibility and scalability of file processing methods are realized.
Patent Information
- Application Number
- CN202110916317.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-10
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2041-08-10
AI Technical Summary
When parsing uploaded data files, existing data management systems need to frequently modify background programs to adapt to changes in demand or field changes, resulting in the program being unscalable.
Provide a file processing method, determine the parsing strategy by identifying the file type, and store the parsed file information in a predetermined format, including at least two arrays, supports multiple file types, and realizes flexible storage of file fields and records. manage.
This method makes the backend program easy to expand, supports multiple file types, clarifys the relationship between uploaded files and backend storage variables, and improves the flexibility and scalability of data processing.
Smart Images

Figure CN113590554B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the fields of computer technology and big data technology, and in particular, to a file processing method, device, electronic device, computer-readable storage medium, and program product. Background Art
[0002] With the continuous development of the information age, each company and organization now has a dedicated data management system to store and manage work data, and a large amount of data generated in daily work needs to be uploaded to the data management system.
[0003] Usually, the data management system needs to parse the uploaded data files. The existing file parsing is generally performed directly in a background program. Once the requirements change or the fields change or expand, the background program needs to be modified again, which is not conducive to the scalability of the program. Summary of the invention
[0004] In view of the above problems, some embodiments of the present disclosure provide a file processing method, apparatus, electronic device, computer-readable storage medium, and program product.
[0005] According to one aspect of an embodiment of the present disclosure, a file processing method is provided, which is executed by an electronic device, and the method includes: receiving a target file; identifying a file type of the target file; determining a file parsing strategy according to the file type, wherein the file parsing strategy corresponds to the file type; parsing file information of the target file according to the determined file parsing strategy, wherein the file information includes multiple file fields and at least one record; and storing the parsed multiple file fields and at least one record of the target file in a predetermined format, wherein the prescribed format includes at least two arrays, and storing the parsed multiple file fields and at least one record of the target file in a predetermined format includes: storing the parsed multiple file fields of the target file in two arrays including a first array and a second array; and storing the parsed at least one record of the target file in at least two arrays including a third array and a fourth array.
[0006] According to some exemplary embodiments, the values of the first array are subscripts of the second array; and / or the values of the third array are subscripts of the fourth array.
[0007] According to some exemplary embodiments, each of the file fields includes a field identifier, position information of the column where the field is located, and a field name, the subscript of the first array includes the field identifier, the value of the first array includes the position information of the column where the field is located, and the value of the second array includes the field name.
[0008] According to some exemplary embodiments, each record includes multiple record data, the number of the multiple record data is consistent with the number of the multiple file fields; and each of the record data includes a data identifier, position information of the column where the record data is located, and a data value, the subscript of the third array includes the data identifier, the value of the third array includes the position information of the column where the record data is located, and the value of the fourth array includes the data value.
[0009] According to some exemplary embodiments, the file information further includes a file version number, and the file processing method further includes: verifying the target file according to the file version number and the number of the file fields.
[0010] According to some exemplary embodiments, the file type includes a text file type, and parsing the file information of the target file according to the determined file parsing strategy specifically includes: parsing the target file line by line to parse out the file information of the target file.
[0011] According to some exemplary embodiments, the file type includes a table file type, and parsing the file information of the target file based on the determined file parsing strategy specifically includes: separately parsing the header part and the data part of the table file to parse the file information of the target file.
[0012] According to some exemplary embodiments, the values of the second array correspond to the values of the fourth array respectively, and the file processing method further includes: according to the values of the second array, verifying the validity of the values of the fourth array corresponding to the values of the second array one by one.
[0013] According to another aspect, a file processing device is provided, the file processing device comprising: a receiving module for receiving a target file; an identification module for identifying a file type of the target file; a policy determination module for determining a file parsing policy according to the file type, wherein the file parsing policy corresponds to the file type; a parsing module for parsing file information of the target file according to the determined file parsing policy, wherein the file information comprises a plurality of file fields and at least one record; and a storage module for storing the parsed plurality of file fields and at least one record of the target file in a predetermined format, wherein the prescribed format comprises at least two arrays, and the storing the parsed plurality of file fields and at least one record of the target file in the predetermined format comprises: storing the parsed plurality of file fields of the target file in two arrays comprising a first array and a second array; and storing the parsed at least one record of the target file in at least two arrays comprising a third array and a fourth array.
[0014] According to some exemplary embodiments, the values of the first array are subscripts of the second array; and / or the values of the third array are subscripts of the fourth array.
[0015] According to another aspect of an embodiment of the present disclosure, there is provided an electronic device, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors execute the above-mentioned file processing method.
[0016] According to another aspect of the embodiments of the present disclosure, a computer-readable storage medium is provided, on which executable instructions are stored. When the instructions are executed by a processor, the processor executes the above-mentioned file processing method.
[0017] According to another aspect of the embodiments of the present disclosure, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the above-mentioned file processing method is implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The above contents and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:
[0019] Figure 1 The application scenario diagram of the file processing method according to the embodiment of the present disclosure is schematically shown;
[0020] Figure 2 A flowchart of a file processing method according to an embodiment of the present disclosure is schematically shown;
[0021] Figure 3A is a schematic diagram of a target file processed by the file processing method according to an embodiment of the present disclosure, wherein the target file is schematically shown to be a text file;
[0022] Figure 3B is a schematic diagram of a target file processed by the file processing method according to an embodiment of the present disclosure, wherein the target file is schematically shown to be a table file;
[0023] Figure 4 A structural block diagram schematically shows a file processing device according to an embodiment of the present disclosure; and
[0024] Figure 5 A block diagram of an electronic device suitable for implementing a file processing method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0025] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.
[0026] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0027] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0028] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.
[0029] For example, in this article, the expressions "field", "record", and "array" can be understood as follows. In a database, a "column" of a table is called a "field", which is a collection of data with the same attributes. Usually, each field has a unique name, called a field name. For example, in the "Address Book" database, "name" and "contact number" are attributes common to all rows in the table, so these columns are called "name" fields and "contact number" fields. Records refer to rows in a table. For example, in the "Address Book" database, fields such as name, age, gender, and email can be included. Each member added to the table contains data such as name, age, gender, and email, and these data of each member constitute a record. An array is an ordered sequence of elements. The individual variables that make up an array are called components of the array, also called elements of the array or values of the array, and sometimes also called subscript variables. The numbers used to distinguish the elements of an array are called subscripts.
[0030] The embodiments of the present disclosure provide a file processing method, device, electronic device, computer-readable storage medium and program product. The file processing method is executed by an electronic device, for example, the method may include the following steps: receiving a target file; identifying the file type of the target file; determining a file parsing strategy according to the file type, wherein the file parsing strategy corresponds to the file type; parsing the file information of the target file according to the determined file parsing strategy, wherein the file information includes multiple file fields and at least one record; and storing the multiple file fields and at least one record of the parsed target file in a predetermined format, wherein the prescribed format includes at least two arrays, and the storing the multiple file fields and at least one record of the parsed target file in a predetermined format includes: storing the multiple file fields of the parsed target file in two arrays including a first array and a second array; and storing the at least one record of the parsed target file in at least two arrays including a third array and a fourth array. In the embodiments of the present disclosure, the file processing method can support multiple file types, clarify the relationship between the uploaded file and the storage variables of the backend, so that the program running on the backend is easy to expand.
[0031] Figure 1 The application scenario diagram of the file processing method according to an embodiment of the present disclosure is schematically shown.
[0032] like Figure 1 As shown, the application scenario 100 according to this embodiment may include various terminal devices 101, 102, 103, a server 105, and a network 104 for connecting the various terminal devices and the server. The network 104 is used to provide a medium for a communication link between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0033] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various client applications can be installed on terminal devices 101, 102, 103, such as banking apps, shopping apps, web browser apps, search apps, instant messaging tools, email clients, social platform software, etc. (only examples).
[0034] The terminal devices 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0035] The server 105 may be a server that provides various services, such as a background server that parses files uploaded by users using the terminal devices 101, 102, and 103, or a background management server that provides support for the browsed websites (for example only). The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests, etc.) to the terminal device.
[0036] It should be noted that the file processing method provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the file processing device provided in the embodiment of the present disclosure can generally be set in the server 105. The file processing method provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105. Accordingly, the file processing device provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105.
[0037] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0038] Figure 2 The flowchart of the file processing method according to the embodiment of the present disclosure is schematically shown. Figure 2 As shown, the file processing method according to the embodiment of the present disclosure may include operations S210 to S250, and the file processing method may be executed by an electronic device, for example, by a processor of the electronic device.
[0039] In operation S210, a target file is received. For example, the target file may be a file uploaded by the terminal device 101, 102, 103. The target file may be a file generated by a banking APP on the terminal device 101, 102, 103, or a file created by a user through input from the terminal device 101, 102, 103.
[0040] In some exemplary embodiments, the target file may include a financial file. It should be noted that in the embodiments of the present disclosure, financial files will be used as an example for description, but the embodiments of the present disclosure are not limited thereto.
[0041] In operation S220, the file type of the target file is identified. For example, the file type of the target file may include a text file type and a table file type. The text file type may include txt and other types, and the table file type may include excel, csv and other types.
[0042] In operation S230, a file parsing strategy is determined according to the file type, wherein the file parsing strategy corresponds to the file type.
[0043] In the embodiments of the present disclosure, different file parsing strategies corresponding to the file types may be adopted according to the file types of the target files. For example, for text file types, a line-by-line parsing strategy may be adopted. For table file types, a strategy of parsing the header part and the data part separately may be adopted.
[0044] It should be noted that the embodiments of the present disclosure are not limited to the two types of text files and table files. Accordingly, the embodiments of the present disclosure are not limited to the above two strategies.
[0045] In operation S240, file information of the target file is parsed according to the determined file parsing strategy, wherein the file information includes a plurality of file fields and at least one record.
[0046] For example, for a text file, according to the determined strategy of line-by-line parsing, the file information of the text file is parsed line by line to obtain multiple file fields and at least one record. For a table file, according to the determined strategy of separately parsing the header part and the data part, the file information of the table file can be parsed separately to obtain multiple file fields and at least one record.
[0047] In operation S250, a plurality of file fields and at least one record of the parsed target file are stored in a predetermined format.
[0048] In an embodiment of the present disclosure, the prescribed format includes at least two arrays. The storing of the multiple file fields and at least one record of the target file parsed in the predetermined format includes: storing the multiple file fields of the target file parsed in two arrays including a first array and a second array; and storing the at least one record of the target file parsed in at least two arrays including a third array and a fourth array.
[0049] For example, the value of the first array is the subscript of the second array; and / or the value of the third array is the subscript of the fourth array.
[0050] For example, each of the file fields includes a field identifier, position information of the column where the field is located, and a field name, the subscript of the first array includes the field identifier, the value of the first array includes the position information of the column where the field is located, and the value of the second array includes the field name.
[0051] For example, each record includes multiple record data, the number of the multiple record data is consistent with the number of the multiple file fields; and each of the record data includes a data identifier, position information of the column where the record data is located, and a data value, the subscript of the third array includes the data identifier, the value of the third array includes the position information of the column where the record data is located, and the value of the fourth array includes the data value.
[0052] Figure 3A It is a schematic diagram of a target file processed by the file processing method according to an embodiment of the present disclosure, which schematically shows the case where the target file is a text file. Figure 3B It is a schematic diagram of a target file processed by the file processing method according to an embodiment of the present disclosure, which schematically shows the case where the target file is a table file.
[0053] In some embodiments, the target file may include a financial data file, such as a salary file, but the embodiments of the present disclosure are not limited thereto.
[0054] Combined with reference Figure 2 and Figure 3A In operation S220, the file type of the target file is identified as a text file type, for example, a txt file type.
[0055] In operation S230, according to the identified text file type, it is determined that the file parsing strategy is a line-by-line parsing strategy, that is, the determined line-by-line parsing strategy corresponds to the identified text file type.
[0056] In operation S240, the system parses the data line by line according to the determined line-by-line parsing strategy. Figure 3A The text file shown in , to obtain file information. That is, multiple file fields and at least one record can be obtained.
[0057] by Figure 3A Taking the text file shown in as an example, the multiple file fields may include sequence number, payee name, receiving account, transfer amount, remarks, etc., and the at least one record includes 3 records, namely "1zhangsan11111111300.00July salary", "2lisi 22222222400.00July salary", and "3wangwu 33333333400.00July salary".
[0058] In operation S250, a plurality of file fields and at least one record of the parsed target file are stored in a predetermined format.
[0059] by Figure 3A Taking the text file shown in as an example, the parsed multiple file fields are stored in two arrays including a first array and a second array.
[0060] For example, the first array may include the following form:
[0061] {['A1', 'lie1'], ['A2', 'lie2'], ['A3', 'lie3'], ['A4', 'lie4'], ['A5', 'lie5']}.
[0062] The second array may include the following forms:
[0063] {['lie1', 'Sequence number'], ['lie2', 'Name of payee'], ['lie3', 'Receiving account'], ['lie4', 'Transfer amount'], ['lie5', 'Remarks']}.
[0064] In an embodiment of the present disclosure, each of the file fields includes a field identifier, position information of the column where the field is located, and a field name. For example, A1, A2, A3, A4, and A5 are the field identifiers of the respective file fields, lie1, lie2, lie3, lie4, and lie5 are the position information of the column where the respective file fields are located, and the sequence number, the name of the payee, the receiving account, the amount transferred, and the remarks are the field names of the respective file fields. The subscript of the first array includes the field identifier, and the value of the first array includes the position information of the column where the field is located, that is, lie1, lie2, lie3, lie4, and lie5. The values of the first array, lie1, lie2, lie3, lie4, and lie5, are the subscripts of the second array, and the values of the second array include the names of the respective fields.
[0065] In this way, two arrays are used to store the file fields of the target file. When the file fields in the target file need to be modified, added or deleted, only the elements in the two arrays need to be modified accordingly, without changing the background program, which is conducive to the development, maintenance and expansion of the background program.
[0066] Likewise, in an embodiment of the present disclosure, at least one record of the target file parsed is stored in at least two arrays including a third array and a fourth array.
[0067] For example, Figure 3A Taking the first record shown in as an example, the third array may include the following form:
[0068] {['B1', 'mxlie1'], ['B2', 'mxlie2'], ['B3', 'mxlie3'], ['B4', 'mxlie4'], ['B5', 'mxlie5']}.
[0069] The fourth array may include the following forms:
[0070] {['mxlie1', '1'], ['mxlie2', 'zhangsan'], ['mxlie3', '11111111'], ['mxlie4', '300.0'], ['mxlie5', 'July salary']}.
[0071] For example, the at least two arrays may further include a fifth array and a sixth array. The fifth array may store the second record.
[0072] For example, the fifth array may include the following form:
[0073] {['mxlie1','2'], ['mxlie2','lisi'], ['mxlie3','22222222'], ['mxlie4','400.0'], ['mxlie5','July salary']}.
[0074] The sixth array may store the third record. For example, the sixth array may include the following format:
[0075] {['mxlie1', '3'], ['mxlie2', 'wangwu'], ['mxlie3', '33333333'], ['mxlie4', '400.0'], ['mxlie5', 'July salary']}.
[0076] by Figure 3ATaking the file shown in as an example, each record includes multiple record data, for example, 5 record data. The number of the multiple record data is consistent with the number of the multiple file fields. For example, the first record includes 5 record data, namely, 1, zhangsan, 11111111, 300.00, and July salary. Each of the record data includes a data identifier, the position information of the column where the record data is located, and a data value. For example, the record data "1" includes a data identifier B1, the position information of the column where the record data is located mxlie1, and the data value 1, and the record data "zhangsan" includes a data identifier B2, the position information of the column where the record data is located mxlie2, and the data value zhangsan, and so on. The subscript of the third array includes the data identifier, and the value of the third array includes the position information of the column where the record data is located. The subscripts of the fourth array, the fifth array, and the sixth array include the position information of the column where the record data is located, and the values of the fourth array, the fifth array, and the sixth array include the data value.
[0077] In this way, at least two arrays are used to store at least one record of the target file. When it is necessary to modify, add or delete a record in the target file, only the elements in the at least two arrays need to be modified accordingly, without changing the background program, which is conducive to the development, maintenance and expansion of the background program.
[0078] Combined with reference Figure 2 and Figure 3B In operation S220, the file type of the target file is identified as a table file type, for example, an excel file type.
[0079] In operation S230, according to the identified table file type, a file parsing strategy is determined as a strategy for parsing the header part and the data part separately, that is, the determined parsing strategy corresponds to the identified table file type.
[0080] In operation S240, the header part and the data part are parsed according to the determined strategy. Figure 3B The table file shown in , to obtain the file information. That is, multiple file fields and at least one record can be obtained.
[0081] by Figure 3BTaking the table file shown in as an example, the multiple file fields may include sequence number, payee name, receiving account, transfer amount, payee contact number, remarks, etc., and the at least one record includes 3 records, namely "1zhangsan 11111111 300.00 34567899 July salary", "2lisi 22222222 400.00 456789697 month salary", and "3wangwu 33333333 400.00 55678969 July salary".
[0082] In operation S250, a plurality of file fields and at least one record of the parsed target file are stored in a predetermined format.
[0083] by Figure 3B Taking the table file shown in as an example, the parsed multiple file fields are stored in two arrays including a first array and a second array.
[0084] For example, the first array includes the following form:
[0085] {['A1', 'lie1'], ['A2', 'lie2'], ['A3', 'lie3'], ['A4', 'lie4'], ['A5', 'lie5'], ['A6', 'lie6']}.
[0086] The second array may include the following forms:
[0087] {['lie1', 'Sequence number'], ['lie2', 'Name of payee'], ['lie3', 'Account number'], ['lie4', 'Amount transferred'], ['lie5', 'Contact number of payee'], ['lie6', 'Remarks']}.
[0088] In an embodiment of the present disclosure, each of the file fields includes a field identifier, the position information of the column where the field is located, and a field name. For example, A1, A2, A3, A4, A5, and A6 are the field identifiers of each file field, lie1, lie2, lie3, lie4, lie5, and lie6 are the position information of the column where each file field is located, and the sequence number, payee name, receiving account, transfer amount, payee contact number, and remarks are the field names of each file field. The subscript of the first array includes the field identifier, and the value of the first array includes the position information of the column where the field is located, that is, lie1, lie2, lie3, lie4, lie5, and lie6. The values of the first array, lie1, lie2, lie3, lie4, lie5, and lie6, are the subscripts of the second array, and the values of the second array include the names of the fields.
[0089] In this way, two arrays are used to store the file fields of the target file. When the file fields in the target file need to be modified, added or deleted, only the elements in the two arrays need to be modified accordingly, without changing the background program, which is conducive to the development, maintenance and expansion of the background program.
[0090] Likewise, in an embodiment of the present disclosure, at least one record of the target file parsed is stored in at least two arrays including a third array and a fourth array.
[0091] For example, Figure 3B Taking the first record shown in as an example, the third array may include the following form:
[0092] {['B1', 'mxlie1'], ['B2', 'mxlie2'], ['B3', 'mxlie3'], ['B4', 'mxlie4'], ['B5', 'mxlie5'], ['B6', 'mxlie6']}.
[0093] The fourth array may include the following forms:
[0094] {['mxlie1', '1'], ['mxlie2', 'zhangsan'], ['mxlie3', '11111111'], ['mxlie4', '300.0'], ['mxlie5', '34567899'], ['mxlie6', 'July salary']}.
[0095] For example, the at least two arrays may further include a fifth array and a sixth array. The fifth array may store the second record. For example, the fifth array may include the following form:
[0096] {['mxlie1','2'], ['mxlie2','lisi'], ['mxlie3','22222222'], ['mxlie4','400.0'], ['mxlie5','45678969'], ['mxlie6','July salary']}.
[0097] The sixth array may store the third record. For example, the sixth array may include the following format:
[0098] {['mxlie1','3'], ['mxlie2','wangwu'], ['mxlie3','33333333'], ['mxlie4','400.0'], ['mxlie5','55678969'], ['mxlie6','July salary']}.
[0099] by Figure 3B Taking the file shown in as an example, each record includes multiple record data, for example, 6 record data. The number of the multiple record data is consistent with the number of the multiple file fields. For example, the first record includes 6 record data, namely, 1, zhangsan, 11111111, 300.00, 34567899, and July salary. Each of the record data includes a data identifier, the position information of the column where the record data is located, and a data value. For example, the record data "1" includes a data identifier B1, the position information of the column where the record data is located mxlie1, and the data value 1, and the record data "zhangsan" includes a data identifier B2, the position information of the column where the record data is located mxlie2, and the data value zhangsan, and so on. The subscript of the third array includes the data identifier, and the value of the third array includes the position information of the column where the record data is located. The subscripts of the fourth array, the fifth array, and the sixth array include the position information of the column where the record data is located, and the values of the fourth array, the fifth array, and the sixth array include the data value.
[0100] In this way, at least two arrays are used to store at least one record of the target file. When it is necessary to modify, add or delete a record in the target file, only the elements in the at least two arrays need to be modified accordingly, without changing the background program, which is conducive to the development, maintenance and expansion of the background program.
[0101] In the embodiments of the present disclosure, the relationship between the uploaded target file and the background storage variable is clarified, and the file processing method and system can support multiple file types, for example, Figure 3A The text file shown and Figure 3B The table files shown in the figure are stored in the form of multiple arrays. When a field or record changes, only the elements of the array need to be changed, and the background program does not need to be changed, which is conducive to the scalability of the program.
[0102] For example, the file information also includes a file version number, such as Figure 3A and Figure 3BThe file version number "1.1" shown in . The file processing method also includes: verifying the target file according to the file version number and the number of the file fields. In some embodiments, the target file may include multiple versions, and different versions may have different numbers of file fields. For example, the target file may include version 1.1, version 1.2, and version 1.3. Accordingly, version 1.1 may have 6 file fields, version 1.2 may have 8 file fields, and version 1.3 may have 9 file fields. In the file processing method, the target file may be verified according to the correspondence between the file version number and the number of the file fields. Exemplarily, when the file version number of the target file is 1.1, if the number of the file fields is 6, the target file is judged to be correct; when the file version number of the target file is 1.1, if the number of the file fields is 7, the target file is judged to be incorrect.
[0103] In some exemplary embodiments, the values of the second array correspond to the values of the fourth array respectively, and the file processing method further comprises: according to the values of each of the second arrays, verifying the validity of the values of the fourth array corresponding to each of the values of the second array one by one. The verification rule can be verified according to the data type, for example, the data type can include a string, a numerical value, etc. The verification rule can also be verified according to the data length and the string length, etc. In the embodiment of the present disclosure, after the data in the target file is stored in each array, the verification is performed, and there is no need to verify the target file one by one, thereby improving the efficiency of data verification.
[0104] For example, for Figure 3A or Figure 3B For the target file shown in , if the value of the second array is “payee name” (i.e. the field name “payee name”), check whether the value of the fourth array corresponding to the “payee name” is a string; if the value of the second array is “transfer amount” (i.e. the field name “transfer amount”), check whether the value of the fourth array corresponding to the “transfer amount” is a numeric value.
[0105] Some exemplary embodiments of the present disclosure also provide a file processing device. Figure 4 The file processing device is described in detail. Figure 4 The structure block diagram of the file processing device according to the embodiment of the present disclosure is schematically shown. Figure 4As shown, the file processing device 40 includes: a receiving module 41, used to receive a target file; an identification module 42, used to identify the file type of the target file; a policy determination module 43, used to determine a file parsing policy according to the file type, wherein the file parsing policy corresponds to the file type; a parsing module 44, used to parse out file information of the target file according to the determined file parsing policy, wherein the file information includes multiple file fields and at least one record; and a storage module 45, used to store the parsed multiple file fields and at least one record of the target file in a predetermined format.
[0106] In an embodiment of the present disclosure, the prescribed format includes at least two arrays, and storing the multiple file fields and at least one record of the target file parsed according to the predetermined format includes: storing the multiple file fields of the target file parsed in two arrays including a first array and a second array; and storing at least one record of the target file parsed in at least two arrays including a third array and a fourth array.
[0107] For example, the value of the first array is the subscript of the second array; and / or the value of the third array is the subscript of the fourth array.
[0108] For example, each of the file fields includes a field identifier, position information of the column where the field is located, and a field name, the subscript of the first array includes the field identifier, the value of the first array includes the position information of the column where the field is located, and the value of the second array includes the field name.
[0109] For example, each record includes multiple record data, the number of the multiple record data is consistent with the number of the multiple file fields; and each of the record data includes a data identifier, position information of the column where the record data is located, and a data value, the subscript of the third array includes the data identifier, the value of the third array includes the position information of the column where the record data is located, and the value of the fourth array includes the data value.
[0110] For example, the file information further includes a file version number, and the file processing device further includes a verification module 46 for verifying the target file according to the file version number and the number of the file fields.
[0111] For example, the file type includes a text file type, and parsing the file information of the target file according to the determined file parsing strategy specifically includes: parsing the target file line by line to parse out the file information of the target file.
[0112] For example, the file type includes a table file type, and parsing the file information of the target file according to the determined file parsing strategy specifically includes: parsing the header part and the data part of the table file respectively to parse the file information of the target file.
[0113] For example, the values of the second array correspond to the values of the fourth array respectively, and the file processing device also includes: a validity verification module 47, which is used to verify the validity of the values of the fourth array corresponding to each value of the second array one by one according to each value of the second array.
[0114] According to some embodiments of the present disclosure, any multiple modules of the receiving module 41, the identification module 42, the policy determination module 43, the parsing module 44, the storage module 45, the verification module 46 and the validity verification module 47 can be combined in one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to some embodiments of the present disclosure, at least one of the receiving module 41, the identification module 42, the policy determination module 43, the parsing module 44, the storage module 45, the verification module 46 and the validity verification module 47 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware or in an appropriate combination of any of them. Alternatively, at least one of the receiving module 41, the identification module 42, the policy determination module 43, the parsing module 44, the storage module 45, the verification module 46 and the validity verification module 47 can be at least partially implemented as a computer program module, which can perform corresponding functions when the computer program module is executed.
[0115] Figure 5 A block diagram of an electronic device suitable for implementing the above-mentioned file processing method according to an embodiment of the present disclosure is schematically shown.
[0116] like Figure 5As shown, the electronic device 500 according to an embodiment of the present disclosure includes a processor 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage part 508 into a random access memory (RAM) 503. The processor 501 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 501 may also include an onboard memory for caching purposes. The processor 501 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0117] In RAM 503, various programs and data required for the operation of electronic device 500 are stored. Processor 501, ROM 502 and RAM 503 are connected to each other via bus 504. Processor 501 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 502 and / or RAM 503. It should be noted that the program can also be stored in one or more memories other than ROM 502 and RAM 503. Processor 501 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.
[0118] According to some embodiments of the present disclosure, the electronic device 500 may further include an input / output (I / O) interface 505, which is also connected to the bus 504. The electronic device 500 may further include one or more of the following components connected to the I / O interface 505: an input portion 506 including a keyboard, a mouse, etc.; an output portion 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 508 including a hard disk, etc.; and a communication portion 509 including a network interface card such as a LAN card, a modem, etc. The communication portion 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed, so that a computer program read therefrom is installed into the storage portion 508 as needed.
[0119] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.
[0120] According to some embodiments of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device. For example, according to some embodiments of the present disclosure, the computer-readable storage medium may include the ROM 502 and / or RAM 503 described above and / or one or more memories other than ROM 502 and RAM 503.
[0121] The embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the item recommendation method provided by the embodiment of the present disclosure.
[0122] The above functions defined in the system / device of the embodiment of the present disclosure are performed when the computer program is executed by the processor 501. According to some embodiments of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0123] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 509, and / or installed from the removable medium 511. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0124] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 509, and / or installed from the removable medium 511. When the computer program is executed by the processor 501, the above functions defined in the system of the embodiment of the present disclosure are performed. According to some embodiments of the present disclosure, the systems, devices, means, modules, units, etc. described above can be implemented by computer program modules.
[0125] According to some embodiments of the present disclosure, the program code for executing the computer program provided by the embodiments of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet).
[0126] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0127] It will be appreciated by those skilled in the art that the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations and / or combinations are not explicitly described in the present disclosure. In particular, the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways without departing from the spirit and teachings of the present disclosure. All of these combinations and / or combinations fall within the scope of the present disclosure.
[0128] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. The scope of the present disclosure is defined by the attached claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.
Claims
1. A file processing method, the file processing method being executed by an electronic device, characterized in that: The method comprises: Receive the target file; Identify the file type of the target file; Determine a file parsing strategy according to the file type, wherein the file parsing strategy corresponds to the file type, wherein the file type includes a text file type and a table file type, for the text file type, a line-by-line parsing strategy is adopted, and for the table file type, a table header part and a data part are parsed separately; Parsing file information of the target file according to the determined file parsing strategy, wherein the file information includes a plurality of file fields and at least one record; and storing the multiple file fields and at least one record of the target file parsed according to a predetermined format, Wherein, the predetermined format includes at least two arrays, The storing of the multiple file fields and at least one record of the target file parsed in a predetermined format includes: storing the parsed multiple file fields of the target file in two arrays including a first array and a second array; and The at least one record of the target file obtained by parsing is stored in at least two arrays including a third array and a fourth array.
2. The file processing method according to claim 1, characterized in that: The value of the first array is the subscript of the second array; and / or the value of the third array is the subscript of the fourth array.
3. The file processing method according to claim 2, characterized in that: Each of the file fields includes a field identifier, position information of the column where the field is located, and a field name. The subscript of the first array includes the field identifier, the value of the first array includes the position information of the column where the field is located, and the value of the second array includes the field name.
4. The file processing method according to claim 2 or 3, characterized in that: Each record includes a plurality of record data, and the number of the plurality of record data is consistent with the number of the plurality of file fields; as well as Each of the record data includes a data identifier, location information of the column where the record data is located, and a data value. The subscript of the third array includes the data identifier, the value of the third array includes the location information of the column where the record data is located, and the value of the fourth array includes the data value.
5. The file processing method according to claim 2 or 3, characterized in that: The file information also includes a file version number. The file processing method further includes: verifying the target file according to the file version number and the number of the file fields.
6. The file processing method according to claim 2 or 3, characterized in that: The values of the second array correspond to the values of the fourth array respectively, The file processing method further includes: verifying the validity of the values of the fourth array corresponding to each value of the second array one by one according to each value of the second array.
7. A file processing device, characterized in that: The file processing device comprises: A receiving module, used for receiving a target file; An identification module, used to identify the file type of the target file; A strategy determination module, used to determine a file parsing strategy according to the file type, wherein the file parsing strategy corresponds to the file type, wherein the file type includes a text file type and a table file type, for the text file type, a line-by-line parsing strategy is adopted, and for the table file type, a table header part and a data part are parsed separately. a parsing module, configured to parse file information of the target file according to the determined file parsing strategy, wherein the file information includes a plurality of file fields and at least one record; and a storage module, used to store the multiple file fields and at least one record of the parsed target file in a predetermined format, Wherein, the predetermined format includes at least two arrays, The storing of the multiple file fields and at least one record of the target file parsed in a predetermined format includes: storing the parsed multiple file fields of the target file in two arrays including a first array and a second array; and The at least one record of the target file obtained by parsing is stored in at least two arrays including a third array and a fourth array.
8. The file processing device according to claim 7, characterized in that: The value of the first array is the subscript of the second array; and / or the value of the third array is the subscript of the fourth array.
9. An electronic device, comprising: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors execute the file processing method according to any one of claims 1 to 6.
10. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the file processing method according to any one of claims 1 to 6.
11. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the file processing method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
File processing method and device, computer equipment and storage medium
CN110069449A
Bill data analysis method and device and server
CN111125225A