File format conversion method and device and storage medium
By obtaining and using the keyword and parameter mapping table generated by the dictionary file, the problem of cumbersomeness and inflexibility of the file format conversion method in complex or large-scale file processing is solved, and efficient and accurate file format conversion is achieved.
Patent Information
- Application Number
- CN202411238125.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-05
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-09-05
AI Technical Summary
Existing file format conversion methods are cumbersome and error-prone when processing complex or large-scale file formats. They lack flexibility and adaptability, and are difficult to quickly adapt to format changes and user needs.
Obtain the dictionary file between the input and output file formats, define the keyword mapping relationship, parameter mapping relationship and data format description, generate the keyword mapping table and parameter mapping table, and use these tables to convert the input file into an output file in the target format. .
It improves the accuracy, consistency and flexibility of file format conversion, reduces manual intervention, improves the efficiency and accuracy of data processing, and ensures that the output file structure and format are as expected.
Smart Images

Figure CN118760656A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data conversion technology, and in particular to a file format conversion method, device and storage medium. Background Art
[0002] In modern engineering and data processing, different software systems and applications often use different file formats to store and exchange data. For example, the input model file (IM) generated by computer-aided engineering (CAE) software during simulation and analysis may need to be converted into an export model file (EX) in another format to facilitate further processing and analysis by other software systems. To achieve data interoperability between these systems, it is necessary to solve the problem of data conversion between file formats. Data format conversion is not just a matter of converting formats; it also involves ensuring the accuracy, consistency, and integrity of the data. Therefore, it is particularly important to develop an efficient and flexible file format conversion method to meet the needs of different formats.
[0003] Although existing file format conversion methods can meet basic needs in many cases, there are still some significant problems. First, the manual process of writing dictionary files is tedious and error-prone, especially when dealing with complex or large-scale file formats. Second, the mapping rules between different formats may be inconsistent, resulting in data loss or errors. Existing tools often lack flexibility and adaptability when dealing with diverse file formats and dynamically changing conversion requirements. In addition, these methods are usually not sensitive enough to changes in file formats and have difficulty quickly adapting to new format specifications or changes in user needs. Due to the existence of these problems, how to improve the flexibility of file format conversion has become an urgent problem to be solved.
[0004] The above content is only used to assist in understanding the technical solution of this application and does not constitute an admission that the above content is prior art. Summary of the Invention
[0005] The purpose of this application is to provide a file format conversion method, device and storage medium, aiming to solve the technical problem of how to improve the flexibility of file format conversion.
[0006] To achieve the above objectives, the present application proposes a file format conversion method, which includes: Obtaining a dictionary file according to an input file format and an output file format, wherein the dictionary file defines a keyword mapping relationship, a parameter mapping relationship, and a data format description between the input file format and the output file format; Obtain a keyword mapping table and a parameter mapping table according to the dictionary file, the keyword mapping relationship, and the parameter mapping relationship; An output file is obtained according to the input file, the data format description, the keyword mapping table and the parameter mapping table.
[0007] In one embodiment, the step of obtaining a keyword mapping table and a parameter mapping table according to the dictionary file, the keyword mapping relationship, and the parameter mapping relationship includes: Read the dictionary file and divide the read content into key-value pairs using preset identifiers; A keyword mapping table and a parameter mapping table between the input file and the output file are constructed according to the keyword mapping relationship, the parameter mapping relationship, and the key-value pairs.
[0008] In one embodiment, the step of obtaining the output file according to the input file, the data format description, the keyword mapping table, and the parameter mapping table includes: Read an input file, identify a first keyword in the input file, and record a first parameter under the first keyword; Obtaining, according to the first keyword, the first parameter, the data format description, the keyword mapping table, and the parameter mapping table, a second parameter and a second keyword corresponding to the first parameter corresponding to the first keyword; An output file is obtained according to the second keyword and the second parameter.
[0009] In one embodiment, the step of obtaining, based on the first keyword, the first parameter, the data format description, the keyword mapping table, and the parameter mapping table, the second parameter and the second keyword corresponding to the first parameter corresponding to the first keyword includes: Traversing the first keyword, searching the keyword mapping table for corresponding second keyword content according to the currently traversed first keyword; Traversing the first parameter, and searching the parameter mapping table for a second parameter corresponding to the first parameter according to the currently traversed first parameter; A second keyword is constructed according to the data format description, the second keyword content and the second parameter.
[0010] In one embodiment, after the step of traversing the first parameter and searching the parameter mapping table for a second parameter corresponding to the first parameter according to the currently traversed first parameter, the method further includes: When no content of the second keyword is found, skip the currently traversed first keyword and continue to traverse the next first keyword; When the second parameter cannot be found, the traversal of the first parameter is stopped, the currently traversed first keyword is skipped, and the traversal of the next first keyword is continued.
[0011] In one embodiment, the step of obtaining a dictionary file according to the input file format and the output file format includes: When a dictionary file corresponding to the input file format and the output file format exists in the configuration file, obtaining the dictionary file from the configuration file; When the dictionary file does not exist in the configuration file, the dictionary file is written according to the input file format, the output file format, the dictionary file structure, the comment character, the line identifier, the keyword delimiter, the sub-object delimiter, and the operator.
[0012] In one embodiment, the step of compiling the dictionary file according to the input file format, the output file format, the dictionary file structure, the annotation characters, the line identifiers, the keyword separators, the sub-object separators, and the operators comprises: Obtaining keyword mapping rules and parameter mapping rules according to the input file format and the output file format; Define the key-value pair structure and organization of the dictionary file; Obtain a dictionary file structure according to the key-value pair structure and the organizational form; Select comment characters, line identifiers, keyword delimiters, sub-object delimiters, and operators; The dictionary file is compiled according to the keyword mapping rule, the parameter mapping rule, the dictionary file structure, the annotation symbol, the row identifier, the keyword separator, the sub-object separator, and the operator.
[0013] In one embodiment, before the step of identifying the first keyword in the input file, the method further includes: Detecting a file header, a separator, an identifier, or an end mark of the input file to obtain a detection result; Obtaining keyword format and parameter format corresponding to the input file format; Verify the input file according to the keyword format and the parameter format to obtain a verification result; When there is no abnormality in the detection result or the verification result, continuing the step of identifying the first keyword in the input file; When there is an abnormality in the detection result or the verification result, the detection result and the verification result are recorded in an error log.
[0014] In addition, to achieve the above-mentioned purpose, the present application also proposes a file format conversion device, the device comprising: A dictionary acquisition module is used to acquire a dictionary file according to an input file format and an output file format, wherein the dictionary file defines a keyword mapping relationship, a parameter mapping relationship, and a data format description between the input file format and the output file format; A mapping table construction module, configured to obtain a keyword mapping table and a parameter mapping table according to the dictionary file, the keyword mapping relationship, and the parameter mapping relationship; The file output module is used to obtain an output file according to the input file, the data format description, the keyword mapping table and the parameter mapping table.
[0015] In addition, to achieve the above-mentioned purpose, the present application also proposes a file format conversion device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the file format conversion method described above.
[0016] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium and stores a computer program. When the computer program is executed by a processor, the steps of the file format conversion method described above are implemented.
[0017] One or more technical solutions proposed in this application have at least the following technical effects: A dictionary file is obtained based on the input and output file formats. The dictionary file defines keyword mappings, parameter mappings, and data format specifications between the input and output file formats. A keyword mapping table and a parameter mapping table are generated based on the dictionary file, the keyword mappings, and the parameter mappings. The output file is then generated based on the input file, the data format specifications, the keyword mapping table, and the parameter mapping table. First, a dictionary file is obtained based on the input and output file formats. This file defines in detail the keyword mappings, parameter mappings, and data format specifications between the input and output formats. Obtaining the dictionary file ensures the comprehensiveness and accuracy of the conversion rules, providing the necessary rules and structure for the conversion process. By clarifying these mappings, errors in data conversion can be effectively reduced, improving data accuracy and consistency. Next, a keyword mapping table and a parameter mapping table are generated based on the definitions in the dictionary file. These tables clearly list the relationships between keywords in the input file and corresponding keywords in the output file, as well as the conversion rules between input and output parameters. Such tables simplify complex conversion tasks, making data processing more intuitive and efficient, and reducing manual intervention. Finally, based on the data, data format description, keyword mapping table, and parameter mapping table in the input file, the data is converted into an output file that conforms to the target format. This ensures that the structure and format of the output file meet the expectations, improving the efficiency and accuracy of data processing. This application not only ensures the accuracy and standardization of data conversion, but also improves the flexibility of file format conversion, making it more convenient and efficient to process data in different formats. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0019] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0020] Figure 1 A flowchart of the first embodiment of the method for converting the file format of this application is provided; Figure 2 A flowchart of the second embodiment of the method for converting the file format of this application is provided; Figure 3 This is a schematic diagram of the module structure of the file format conversion device according to an embodiment of the present application; Figure 4Schematic diagram of the device structure of the hardware operating environment involved in the file format conversion method in the embodiment of the present application.
[0021] The purpose, features and advantages of this application will be further explained with reference to the accompanying drawings in conjunction with the embodiments. DETAILED DESCRIPTION
[0022] It should be understood that the specific embodiments described herein are merely used to explain the technical solutions of the present application and are not intended to limit the present application.
[0023] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0024] In modern engineering and data processing, data interoperability between different software systems requires solving file format conversion problems to ensure data accuracy, consistency, and integrity. Although existing conversion methods can meet basic requirements, they have limitations in handling complex file formats, maintaining data mapping consistency, and adapting to format changes and user needs. Therefore, developing an efficient and flexible conversion method is crucial to meet diverse format requirements.
[0025] The main solution of the embodiment of the present application is: first, ensure the accuracy of the conversion rules by obtaining a dictionary file containing the mapping relationship between input and output formats; then generate keyword and parameter mapping tables based on the dictionary file to simplify the conversion task; finally, use these mapping tables to convert the input file data into an output file in the target format, thereby improving the efficiency and accuracy of file format conversion.
[0026] It should be noted that the execution subject of the embodiments of the present application may be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, mobile phone, etc., or an electronic device capable of implementing the above functions, a file conversion system, etc. The following uses the file conversion system as an example to illustrate this embodiment and the following embodiments.
[0027] Based on this, the embodiment of the present application provides a method for converting file formats. Figure 1 , Figure 1 This is a flowchart of the first embodiment of the file format conversion method of this application.
[0028] In this embodiment, the file format conversion method includes steps S10 to S30: Step S10, obtaining a dictionary file according to the input file format and the output file format, wherein the dictionary file defines a keyword mapping relationship, a parameter mapping relationship, and a data format description between the input file format and the output file format; It's important to note that the input file format (IM file format) refers to the structure and specifications of the source file. These files are used to store and organize data for processing or analysis. The input file format includes information such as the file's overall structure, keywords, parameters, and their data types. In the context of file format conversion, the input file format is the format of the data file used as input during the conversion process. This format defines how the data is organized and represented in the file. The conversion tool must parse this format to extract the data and prepare it for conversion. The output file format (EX file format) refers to the structure and specifications of the target file. These files are used to store the converted data. The output file format defines how the data should be organized and represented in the target file. During file format conversion, the output file format is the format of the resulting file after conversion. The conversion tool must reorganize and format the data in the input file according to this format to generate an output file that meets the target requirements. A dictionary file is a configuration file that defines the mapping between the input file format and the output file format. The dictionary file details how to convert data items in the input file into data items in the output file, including keyword mappings, parameter mappings, and data format descriptions. During file format conversion, a dictionary file acts as a bridge, containing conversion rules and logic. The dictionary file guides the conversion tool on how to parse the input file, map data items to the output file, and ensure accuracy and consistency. Keyword mappings refer to the mapping rules between keywords (such as field names or labels) in the input file format and corresponding keywords in the output file format. This mapping defines how to convert keywords from the input file to keywords in the output file. Keyword mappings in the dictionary file help the conversion tool identify and match keywords in the input file with keywords in the output file. For example, MAT_ELASTIC (a keyword used to identify elastic properties of a material) in the input file might need to be mapped to MAT1 (an input format used to represent one-dimensional elastic materials) in the output file. The dictionary file defines this mapping. Parameter mappings refer to the mapping rules between parameters (such as data values or attributes) in the input file format and corresponding parameters in the output file format. This mapping defines how parameter values in the input file are converted to parameter values in the output file. During file format conversion, parameter mappings help ensure that data values in the input file are correctly mapped to the output file. For example, the value of PARAM1 in the input file may need to be converted to VALUE1 in the output file. The dictionary file defines this mapping, including any necessary data conversions or calculations. A data format specification is a detailed description of the data structure, data types, and format specifications for the input and output file formats. It includes how to parse and format data to conform to the requirements of the target file format.In the dictionary file, the data format description provides format specifications for input and output files, including the type of data items (such as integers, floating-point numbers, strings), the arrangement of data (such as row and column formats), and any specific format requirements (such as date format, numerical precision, etc.). This description ensures that the conversion tool can correctly process and format the data to generate output files that meet the target specifications.
[0029] It's understandable that during the file format conversion process, a dictionary file is first required based on the input file format (IM file format) and the output file format (EX file format). The primary function of this dictionary file is to specify how to convert the data in the input file into the format that meets the output file's requirements. Specifically, the dictionary file defines three core elements: keyword mappings, which map keywords in the input file to corresponding keywords in the output file; parameter mappings, which map parameters in the input file to corresponding parameters in the output file, including any necessary conversion rules or calculation formulas; and data format specifications, which describe in detail the data structure, data type, and format specifications in the input and output files. These definitions ensure the correctness and consistency of the data during the conversion process, allowing for accurate and error-free conversion from one file format to another.
[0030] As an example, the step of obtaining a dictionary file according to the input file format and the output file format includes: when a dictionary file corresponding to the input file format and the output file format exists in the configuration file, obtaining the dictionary file from the configuration file; when the dictionary file does not exist in the configuration file, writing the dictionary file according to the input file format, the output file format, the dictionary file structure, the comment character, the line identifier, the keyword delimiter, the sub-object delimiter and the operator.
[0031] A configuration file contains system or application settings, defining program behavior and parameters. In the context of file format conversion, a configuration file includes various settings, file paths, format specifications, and other information. The configuration file may list the path or name of a dictionary file used for file format conversion. If a dictionary file matching the input and output file formats already exists in the configuration file, it can be directly retrieved from the configuration file; otherwise, a dictionary file must be created based on the relevant information. The dictionary file structure refers to the organization and format specifications of the dictionary file, including how keyword mappings, parameter mappings, and data format specifications are defined and stored. The dictionary file structure determines the arrangement and storage of data within the dictionary file. It includes how conversion rules are identified and organized, and how the relationship between input and output file formats is represented in a structured form. For example, a dictionary file may be divided into different sections, such as mapping rules and format specifications, and defines how this information is parsed and used for conversion. Comments are symbols used to add comments to files. These comments are not parsed or processed by the program and are intended for human reading only. Comments are used to insert explanations or descriptions of the file content within a dictionary file, aiding in understanding the mapping rules and data structure. For example, comment characters such as `#`, ` / / `, and `$` can be used to add explanatory text to a dictionary file without affecting the file's actual functionality. A line identifier is a symbol used to mark the beginning of each line in a file, typically used to separate different rules or data entries. In a dictionary file, a line identifier, such as `*` or `@`, identifies the type or function of each line of data, helping the program or user distinguish between different mapping rules or configuration items. Line identifiers clearly indicate the content and purpose of each line, ensuring a clearer parsing process for the dictionary file. Keyword delimiters are symbols used to separate keywords and their corresponding values in a dictionary file. In a dictionary file, keyword delimiters help distinguish and map keywords in the input file format from keywords in the output file format. For example, using `@` or `=` as delimiters separates input keywords from output keywords, thus clarifying the mapping relationship. Subobject delimiters are symbols used to separate parameters or subobjects within a keyword within a file. In a dictionary file, subobject delimiters are used to identify and separate parameters or subobjects within a keyword. For example, use `%` or `.` to separate different parameters or attributes, ensuring that data is organized and parsed according to the expected structure. Operators are symbols used to perform calculations or logical operations within dictionary files. In dictionary files, operators (such as `+`, `-`, `*`, and ` / `) are used to define how to calculate or transform data in the input file to conform to the format requirements of the output file. For example, operators can be used to perform numerical calculations, data conversions, or logical judgments to ensure that data meets specific rules and requirements during the conversion process.
[0032] First, check whether the configuration file already contains a dictionary file corresponding to the specified input and output file formats. If such a dictionary file exists, extract it directly from the configuration file for conversion. If the corresponding dictionary file does not exist, create a new dictionary file. During the dictionary file creation process, based on the requirements of the input and output file formats and the design of the dictionary file structure, define how to map the data in the input file to the output file. This includes determining the annotation character (used to add file descriptions and comments), line identifiers (used to mark each line with a rule or configuration item), keyword delimiters (used to separate input and output keywords), sub-object delimiters (used to separate parameters or data items under a keyword), and operators (used to define data calculation and transformation rules). Through these steps, the created dictionary file can accurately perform the conversion from the input file format to the output file format.
[0033] As an example, the steps of writing the dictionary file according to the input file format, the output file format, the dictionary file structure, annotation symbols, row identifiers, keyword separators, sub-object separators and operators include: obtaining keyword mapping rules and parameter mapping rules according to the input file format and the output file format; defining the key-value pair structure and organizational form of the dictionary file; obtaining the dictionary file structure according to the key-value pair structure and the organizational form; selecting annotation symbols, row identifiers, keyword separators, sub-object separators and operators; and writing the dictionary file according to the keyword mapping rules, the parameter mapping rules, the dictionary file structure, the annotation symbols, the row identifiers, the keyword separators, the sub-object separators and the operators.
[0034] Keyword mapping rules are the rules for matching and converting keywords (such as field names and labels) in the input file format to corresponding keywords in the output file format. In file format conversion, keyword mapping rules specify the corresponding position of each keyword in the input file in the output file. For example, if the input file uses Material_ID to represent a material number, and the output file uses MAT_ID, the keyword mapping rules define how Material_ID is mapped to MAT_ID. These rules ensure data consistency and accuracy between different formats. Parameter mapping rules are the rules for mapping parameter values (such as values and attributes) in the input file format to the corresponding parameter values in the output file format. In file format conversion, parameter mapping rules define how data values in the input file are converted to data values in the output file. For example, the parameter Density in the input file may need to be converted to Mass_Density in the output file, and this may involve data unit conversion or formatting. Parameter mapping rules ensure the correct conversion of values and attributes between different formats. The key-value structure refers to how data is organized and stored within a dictionary file. Each key and value pair together defines a transformation rule. Within a dictionary file, the key-value structure determines how keyword mappings and parameter mapping rules are stored in a structured manner. The key represents a keyword or parameter in the input or output file format, while the value represents the corresponding mapping rule or data format description. For example, `"Material_ID" : "MAT_ID"` represents a key-value pair, where `"Material_ID" is the keyword for the input format and `"MAT_ID" is the keyword for the output format. Organization refers to the layout and arrangement of data and rules within a dictionary file, including how the key-value structure is organized into a logically coherent form. Organization involves the overall structural design of the dictionary file, such as how data is segmented, categorized, and arranged. It determines the file's readability and usability. Organization can include grouping, sorting, and hierarchical structures to ensure that the dictionary file can intuitively represent and manage different mapping rules and transformation logic. The dictionary file structure refers to the overall layout and format of the dictionary file, including how mapping rules, data format specifications, and other configuration information are defined and stored. The dictionary file structure encompasses the definitions of all file elements, such as comment characters, line identifiers, keyword delimiters, and sub-object delimiters, as well as how mapping rules and data format specifications are organized into a valid file based on these definitions. The dictionary file structure ensures that the file can be correctly parsed and applied during file format conversion.
[0035] When compiling a dictionary file, first determine the keyword and parameter mapping rules based on the input and output file formats. These rules specify how to convert keywords and parameter values in the input file into their corresponding items in the output file format. Next, define the dictionary file's key-value pair structure and organization, deciding how to store and arrange these rules in a structured manner. Based on this key-value pair structure and organization, construct the overall structure of the dictionary file. Then, select appropriate annotation characters, line identifiers, keyword delimiters, sub-object delimiters, and operators. These symbols and markers will be used to define and distinguish different sections and rules in the dictionary file. Finally, based on the defined mapping rules, dictionary file structure, and selected symbols, compile the dictionary file to ensure that it accurately guides the data conversion from the input file format to the output file format.
[0036] Step S20, obtaining a keyword mapping table and a parameter mapping table according to the dictionary file, the keyword mapping relationship, and the parameter mapping relationship; It should be noted that the keyword mapping table is a table or data structure used to display and manage the mapping relationship between keywords (field names, labels, etc.) in the input file format and the corresponding keywords in the output file format. The keyword mapping table lists in detail the keywords in each input file format and their corresponding keywords in the output file format. This table helps the conversion tool identify and match keywords, thereby ensuring that the input data is correctly mapped to the output format. For example, if the input file uses the keyword Material_ID and the output file uses MAT_ID, the keyword mapping table will record this correspondence for accurate replacement and processing during the conversion process. The parameter mapping table is a table or data structure used to display and manage the mapping relationship between parameter values (such as numerical values, attributes, etc.) in the input file format and the corresponding parameter values in the output file format. The parameter mapping table details each parameter in the input file format and its corresponding parameter in the output file format, including any necessary conversion rules or calculation formulas. This table helps the conversion tool to follow the correct rules when converting the data values in the input file to the output format. For example, if the parameter Density in the input file needs to be converted to Mass_Density in the output file, and if a unit conversion is required, the parameter mapping table will define this correspondence and conversion details.
[0037] It can be understood that in the process of obtaining the keyword mapping table and the parameter mapping table based on the dictionary file, the keyword mapping relationship and the parameter mapping relationship, first, all the keyword mapping relationships and the parameter mapping relationships are extracted and organized from the dictionary file. These mapping relationships define how the keywords and parameters in the input file format correspond to the keywords and parameters in the output file format. Then, using these mapping relationships, a keyword mapping table is created, which lists each keyword in the input file format and its corresponding keyword in the output file format to ensure the consistency of the data structure. Next, a parameter mapping table is compiled, which shows each parameter in the input file format and its corresponding parameter in the output file format, including the necessary conversion rules and calculation formulas to ensure the correct conversion of data values. Through these two tables, the conversion tool can accurately map the input data to the output format, thereby achieving effective conversion of the file format.
[0038] As an example, the steps of obtaining a keyword mapping table and a parameter mapping table according to the dictionary file, the keyword mapping relationship and the parameter mapping relationship include: reading the dictionary file, dividing the read content into key-value pairs through a preset identifier; and constructing a keyword mapping table and a parameter mapping table between the input file and the output file according to the keyword mapping relationship, the parameter mapping relationship and the key-value pairs.
[0039] Preset identifiers refer to symbols or characters used in dictionary files to mark and separate different data items or data segments. These identifiers help the system identify and extract various parts of the file. Preset identifiers are used in dictionary files to indicate different types or levels of data, such as to separate key-value pairs or identify different mapping rules. For example, if a dictionary file uses ':' as a preset identifier, each pair of keywords and parameters in the file can be separated by ':', such as Material_ID:MAT_ID. When reading a dictionary file, the system will split the data into keys and values based on this identifier, and then use it to build keyword mapping tables and parameter mapping tables. Key-value pairs are the basic units of data organization, where "key" is an identifier or label, and "value" is the data or information associated with the key. In the dictionary file, the key-value pairs represent the basic structure of the mapping relationship. For example, a key-value pair may include a keyword in the input file format and its corresponding keyword in the output file format, or a parameter in the input file format and its corresponding parameter in the output file format. For example, the key-value pair Material_ID:MAT_ID means that Material_ID is used as the keyword in the input file, while MAT_ID is used to represent the same concept in the output file. Through these key-value pairs, keyword mapping tables and parameter mapping tables can be constructed to ensure the correct conversion of data between input files and output files.
[0040] First, the dictionary file's contents are read and the data is segmented into key-value pairs using predefined identifiers (such as colons `:` or equal signs `=`). For example, in the dictionary file, `Material_ID: MAT_ID` and `Density: Mass_Density` represent the correspondence between input keywords and output keywords, respectively. Next, these key-value pairs are used along with predefined keyword and parameter mappings to construct keyword and parameter mapping tables. The keyword mapping table shows how each keyword in the input file maps to its corresponding keyword in the output file, while the parameter mapping table shows how each parameter in the input file is converted to its corresponding parameter in the output file, including any necessary conversion rules or calculation methods. These tables enable efficient data conversion between the input and output files.
[0041] Step S30: obtaining an output file according to the input file, the data format description, the keyword mapping table, and the parameter mapping table.
[0042] It's important to note that an input file refers to the original file to be converted. It contains the data to be processed, organized in a specific format. This file is the starting point of the conversion process, and its data is processed and converted according to the specified conversion rules. In the context of file format conversion, the input file is the file that actually stores the data, organized and stored in a specific file format (such as IM format). The input file's contents are read and conversion rules are applied to the data using keyword and parameter mapping tables to convert the data into the desired output format. For example, the input file might be a CAE file, CSV file, or XML file containing material data, along with the keywords and parameters to be converted. The output file is the target file after the conversion, organizing the data in the new format. The output file is the result of the conversion process, where the data is processed according to the conversion rules and presented in the new format. In the file format conversion process, the output file is the final file generated, with the data reorganized and formatted according to the input file's contents and the conversion rules. The format of the output file (e.g., EX format) is different from that of the input file and may include different keywords, parameter formats, and data structures. The output file is the final result of the conversion and is designed to meet specific format requirements or be compatible with other systems. For example, the output file may be a converted Excel file, bdf file, JSON file, or other file that meets the target format requirements.
[0043] As you can understand, first, the raw data is read from the input file and organized according to a specific format. Next, the target format and data structure of the output file are determined according to the requirements of the data format specification. Then, using the keyword mapping table, the keywords in the input file are converted into the keywords required in the output file, ensuring correct keyword matching and conversion. Subsequently, the parameter mapping table is applied to convert the data values in the input file into the corresponding values in the output file according to the specified conversion rules or calculation formulas. Finally, all the converted data is organized and stored according to the format requirements of the data format specification, generating an output file that meets the target format requirements. This process ensures that the data conversion from the input file to the output file is accurate and meets the expected format specifications.
[0044] This embodiment provides a file format conversion method. A dictionary file is obtained based on an input file format and an output file format. The dictionary file defines keyword mapping relationships, parameter mapping relationships, and data format specifications between the input and output file formats. A keyword mapping table and a parameter mapping table are generated based on the dictionary file, the keyword mapping relationships, and the parameter mapping relationships. An output file is generated based on the input file, the data format specifications, the keyword mapping table, and the parameter mapping table. First, a dictionary file is obtained based on the input and output file formats. This file defines in detail the keyword mapping relationships, parameter mapping relationships, and data format specifications between the input and output formats. Obtaining the dictionary file ensures the comprehensiveness and accuracy of the conversion rules, providing the necessary rules and structure for the conversion process. By clarifying these mapping relationships, errors in data conversion can be effectively reduced, and data accuracy and consistency can be improved. Next, a keyword mapping table and a parameter mapping table are generated based on the definitions in the dictionary file. These tables clearly list the relationships between keywords in the input file and corresponding keywords in the output file, as well as the conversion rules between input parameters and output parameters. Such tables simplify complex conversion tasks, making data processing more intuitive and efficient, and reducing manual intervention. Finally, based on the data in the input file, the data format description, the keyword mapping table, and the parameter mapping table, the data is converted into an output file that conforms to the target format. This ensures that the structure and format of the output file meet the expectations, improving the efficiency and accuracy of data processing. This embodiment not only ensures the accuracy and standardization of file format conversion, but also increases the flexibility of file format conversion, making the processing of data in different formats more convenient and efficient.
[0045] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above embodiment 1 can be referred to the above introduction and will not be described in detail later. Figure 2 , Figure 2This is a flowchart of the second embodiment of the file format conversion method of the present application. Step S30 of the file format conversion method includes steps S31 to S33: Step S31, reading an input file, identifying a first keyword in the input file, and recording a first parameter under the first keyword; It should be noted that the first keyword refers to a specific identifier or label identified in the input file, which is used to mark or classify data items. When reading the input file, the system first identifies and extracts the first keyword in the input file. This keyword is used to mark the main field or attribute of the data, such as Material_ID or Density, which helps the system determine the category or type of the data. The first parameter refers to the data value or attribute value associated with the first keyword. After identifying the first keyword, the system will record the first parameter associated with it. This parameter is the data value under the first keyword. For example, for the keyword Material_ID, its first parameter may be a specific material identifier such as MAT123, etc. The first parameter is the specific value or data item of the keyword.
[0046] As you can understand, the data is first read from the input file. Next, the system identifies the first keyword in the input file, a specific identifier used to tag or categorize data, such as `Material_ID` or `Density`. After determining the first keyword, the system then searches for the specific data item associated with that keyword, namely the first parameter. For example, if the data value under the `Material_ID` keyword in the input file is `MAT123`, then `MAT123` is the first parameter. This process ensures that key information is extracted and recorded from the input file, providing foundational data for subsequent data processing and conversion.
[0047] As an example, before the step of identifying the first keyword in the input file, it also includes: detecting the file header, delimiter, identifier or end mark of the input file to obtain a detection result; obtaining the keyword format and parameter format corresponding to the input file format; verifying the input file according to the keyword format and the parameter format to obtain a verification result; when there is no abnormality in the detection result or the verification result, continuing the step of identifying the first keyword in the input file; when there is an abnormality in the detection result or the verification result, recording the detection result and the verification result in the error log.
[0048] The file header refers to the beginning of a file, which usually contains information about the file structure or file type, such as file format, version number, creation date, etc. In the input file, the file header is used to provide metadata or identification information about the file content to help the system correctly understand and parse the structure of the file. For example, the file header of a comma-separated values (CSV) file may contain column names to indicate the meaning of each column of data. A delimiter refers to a character or string used to separate different data items or fields in a file. In the input file, the delimiter helps the system distinguish data fields. For example, in a CSV file, a comma (,) serves as a field delimiter to separate different data columns. In other formats, tabs, spaces, or other symbols may be used as delimiters. An identifier is a specific symbol or string used to mark or identify data items in a file. Identifiers are used in input files to distinguish and mark data blocks or fields, such as tags or field names, etc. For example, in an XML file, an identifier can be a tag name such as <material> , used to mark related data parts. The end tag refers to the symbol or string used to identify the end of a data segment or file. The end tag is used to determine the end of a data segment or the end of a file. For example, in an XML file, the end tag is< / material> Logo <material>The end of a data block. In other file formats, a specific character sequence may be used as the end marker. A test result refers to the status information or feedback obtained after testing a file header, delimiter, identifier, or end marker. The test result provides verification information about the file format and structure, such as whether the expected delimiter or identifier was found or whether the file header was parsed correctly. The test result can be a success or failure, indicating whether the format requirements are met. The keyword format refers to the structure and representation of keywords in a file, including the keyword type, length, and allowed characters. The keyword format defines the specifications for keywords in the input file. For example, keywords must be a combination of letters and numbers and no longer than 20 characters. This format ensures correct parsing and processing of keywords. The parameter format refers to the structure and representation of parameters in a file, including the parameter type, length, and format requirements. The parameter format defines the specifications for parameters in the input file, such as the data type (string, integer, floating-point number, etc.), length limit, and format (such as the date format YYYY-MM-DD), ensuring correct parsing and processing of parameters. A validation result is the status information or feedback obtained after validating an input file, indicating whether the file conforms to the expected format and structure. The validation result provides feedback on whether the file content complies with the keyword and parameter formats. If the file complies with the specifications, the validation result is successful; otherwise, the result indicates an anomaly in the format or content. An error log is a file or data record that records anomalies or errors discovered during the detection and verification process. Error logs are used to record problems encountered during file processing, such as format errors and unrecognized delimiters or identifiers. These records help developers or system administrators diagnose and fix problems, ensuring the correctness and reliability of file processing.
[0049] Before identifying the first keyword in the input file, a series of preprocessing steps are required. First, the file header, delimiter, identifier or end tag of the input file are detected to obtain the corresponding test results. These steps confirm whether the file structure meets expectations, such as whether the file header exists, whether the delimiter is correct, and whether the identifier and end tag are complete. Next, the keyword format and parameter format corresponding to the input file format are obtained. These formats define the structural requirements of the keywords and parameters in the file. Then, the input file is verified according to these formats to obtain the verification results. This step ensures that the data format and structure of the input file meet the specified requirements. If no abnormalities are found in the test results and verification results, the system will continue to identify the first keyword in the input file. However, if there are abnormalities in the test results or verification results, the system will record these abnormalities in the error log and provide detailed information for further analysis and correction. This process ensures that the structure and content of the input file meet expectations, which helps the subsequent data processing and conversion steps to proceed smoothly.
[0050] Step S32: Obtain a second parameter and a second keyword corresponding to the first parameter and corresponding to the first keyword according to the first keyword, the first parameter, the data format description, the keyword mapping table, and the parameter mapping table; It should be noted that the second parameter refers to the target parameter value obtained by converting the first keyword and first parameter through the data format description, keyword mapping table, and parameter mapping table. Based on the first keyword, first parameter, and the relevant conversion rules (data format description, keyword mapping table, and parameter mapping table), the system converts the first parameter into the corresponding second parameter. The second parameter is the target value to be used in the output file. For example, if the first parameter MAT123 in the input file needs to be mapped to a certain attribute value in the output file, this value is the second parameter, such as Material_Code. The second keyword is an identifier or label associated with the second parameter in the output file format, used to mark or classify the data item. Based on the mapping rules, the system determines the second keyword, i.e., the corresponding keyword in the output file, which is used to mark or store the value of the second parameter. For example, if the first parameter MAT123 of the first keyword Material_ID in the input file corresponds to the keyword MAT_ID in the output file, then MAT_ID is the second keyword. The second keyword is used to identify or classify the data item in the output file.
[0051] It can be understood that data conversion is first performed using the identified first keyword and first parameter in combination with the data format description, keyword mapping table, and parameter mapping table. Specifically, the system determines the second keyword to be used in the output file based on the first keyword, and finds the corresponding second parameter value through the parameter mapping table based on the value of the first parameter. The data format description provides the format requirements of the output file, while the keyword mapping table and parameter mapping table define the conversion rules from input data to output data. By applying these rules, the system converts the first keyword and the first parameter into the second keyword and the second parameter, ensuring that the data is correctly mapped and organized according to the target format during the conversion process. This process achieves accurate conversion of input data to output data, meeting format specifications and data consistency requirements.
[0052] As an example, the steps of obtaining the second parameter and the second keyword corresponding to the first parameter corresponding to the first keyword according to the first keyword, the first parameter, the data format description, the keyword mapping table and the parameter mapping table include: traversing the first keyword, and searching for the corresponding second keyword content in the keyword mapping table according to the currently traversed first keyword; traversing the first parameter, and searching for the second parameter corresponding to the first parameter in the parameter mapping table according to the currently traversed first parameter; and constructing the second keyword according to the data format description, the second keyword content and the second parameter.
[0053] The second keyword content refers to the specific information or value of the target keyword corresponding to the first keyword found in the keyword mapping table. It is used to determine the detailed content of the second keyword to be used in the output file. When traversing the first keyword and searching in the keyword mapping table, the content found is the second keyword content. This usually includes specific information such as the name, label, or identifier of the second keyword, which is used to define the keyword to be used in the output file. For example, if the first keyword corresponds to Output_Key_1 in the mapping table, then Output_Key_1 is the second keyword content.
[0054] First, each identified first keyword is iterated over and its corresponding second keyword content is searched in the keyword mapping table. The second keyword content is defined in the mapping table and is used to determine the actual keyword used in the output file. For example, the first keyword "Material_ID" might correspond to the second keyword content "Product_Code" in the mapping table. Next, each identified first parameter is iterated over and its corresponding second parameter is searched in the parameter mapping table. The second parameter is the target value converted from the first parameter using the parameter mapping table. For example, the first parameter "MAT123" might correspond to the second parameter "Code_456". After obtaining the second keyword content and second parameter, these information are combined according to the data format specification to construct the final second keyword. Specifically, this involves combining the second keyword content with the second parameter to form a complete second keyword according to the format and structure specified in the data format specification. For example, if the data format specification requires the second keyword and second parameter to be combined into a single field, "Product_Code" and "Code_456" might be combined into "Product_Code: Code_456". These steps ensure accurate conversion and formatting of data from input to output.
[0055] As an example, after traversing the first parameter and searching the parameter mapping table for the second parameter corresponding to the first parameter according to the currently traversed first parameter, the method further includes: when the second keyword content cannot be found, skipping the currently traversed first keyword and continuing to traverse the next first keyword; when the second parameter cannot be found, stopping traversing the first parameter, skipping the currently traversed first keyword, and continuing to traverse the next first keyword.
[0056] If the corresponding second keyword content cannot be found in the keyword mapping table, the system will skip the currently traversed first keyword and continue to process the next first keyword. After traversing the first parameter and searching for the corresponding second parameter in the parameter mapping table based on the current parameter, if the corresponding second parameter cannot be found, further processing of the current first parameter will be stopped, and the currently traversed first keyword will be skipped, and the traversal of the next first keyword will continue. Specifically, if there is no matching second parameter in the parameter mapping table, this means that the current first keyword and its related parameters cannot be effectively converted, and the system will no longer process the current keyword to avoid generating invalid or incomplete data. On the contrary, the system will continue to process the next first keyword to ensure that as much data as possible is correctly processed and converted. This processing method ensures the accuracy and effectiveness of data processing, reduces possible errors or omissions by skipping keywords and parameters that cannot be processed, and ensures the smoothness and consistency of data processing.
[0057] Step S33: Obtain an output file according to the second keyword and the second parameter.
[0058] As you can understand, the system first combines the second keyword and second parameter to form the required format and content for the output file. For example, if the second keyword is Product_Code and the second parameter is Code_456, the system will organize these data items in the file according to the predefined output file format. Next, the system places these keywords and parameters in the appropriate file structure, such as within designated fields or tags, based on the data format specifications. Ultimately, the system creates a file that conforms to the output file format requirements and contains the data defined by the second keyword and second parameters. This process ensures that the output file, converted from the input file, is complete, accurate, and conforms to the expected format specifications, providing valid data output for subsequent data processing and analysis.
[0059] This embodiment reads an input file, identifies the first keyword in the input file, and records the first parameter associated with the first keyword. Based on the first keyword, the first parameter, the data format specification, the keyword mapping table, and the parameter mapping table, the system obtains the second parameter and the second keyword corresponding to the first keyword and the first parameter. Finally, the system generates an output file based on the second keyword and the second parameter. First, the system reads data from the input file, identifies and records the first keyword and its corresponding first parameter. This step ensures accurate extraction of key information and lays the foundation for subsequent processing. Next, based on the first keyword and the first parameter, the system searches for and determines the corresponding second keyword and second parameter in conjunction with the data format specification, the keyword mapping table, and the parameter mapping table. This step accurately maps the input data to the required format for the output data, ensuring the accuracy and consistency of the data conversion. Finally, the system generates an output file based on the obtained second keyword and second parameter, formatting the processed data into the predetermined output format. This process ensures that the generated output file meets the requirements and ensures the accuracy and integrity of the data. This process improves the efficiency and accuracy of data processing, thereby effectively enhancing the flexibility and reliability of file format conversion.
[0060] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the file format conversion method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0061] This application also provides a file format conversion device, please refer to Figure 3 , the file format conversion device includes: A dictionary acquisition module 10 is configured to acquire a dictionary file according to an input file format and an output file format, wherein the dictionary file defines a keyword mapping relationship, a parameter mapping relationship, and a data format description between the input file format and the output file format; A mapping table construction module 20, configured to obtain a keyword mapping table and a parameter mapping table according to the dictionary file, the keyword mapping relationship, and the parameter mapping relationship; The file output module 30 is configured to obtain an output file according to the input file, the data format description, the keyword mapping table, and the parameter mapping table.
[0062] The file format conversion device provided in this application utilizes the file format conversion method described in the aforementioned embodiment to address the technical problem of improving the flexibility of file format conversion. Compared to the prior art, the beneficial effects of the file format conversion device provided in this application are the same as those of the file format conversion method described in the aforementioned embodiment. Other technical features of the file format conversion device are the same as those disclosed in the aforementioned embodiment and are not further elaborated here.
[0063] The present application provides a file format conversion device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the file format conversion method in the above-mentioned embodiment 1.
[0064] Reference below Figure 4 , which shows a schematic diagram of the structure of a file format conversion device suitable for implementing the embodiments of the present application. The file format conversion device in the embodiments of the present application may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), in-vehicle terminals (such as in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 4 The file format conversion device shown is merely an example and should not limit the functions and scope of use of the embodiments of the present application.
[0065] like Figure 4 As shown, the file format conversion device may include a processing device 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes based on programs stored in a read-only memory (ROM) 1002 or programs loaded from a storage device 1003 into a random access memory (RAM) 1004. RAM 1004 also stores various programs and data required for the operation of the file format conversion device. Processing device 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems may be connected to I / O interface 1006: input devices 1007, such as a touchscreen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008, such as a liquid crystal display (LCD), speaker, vibrator, etc.; storage device 1003, such as a magnetic tape or hard disk; and communication device 1009. The communication device 1009 can allow the file format conversion device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows a file format conversion device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or provided instead.
[0066] In particular, according to the embodiments disclosed in the present application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments disclosed in the present application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program comprising program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0067] The file format conversion device provided by this application, employing the file format conversion method described in the aforementioned embodiment, can solve the technical problem of improving the flexibility of file format conversion. Compared to the prior art, the beneficial effects of the file format conversion device provided by this application are the same as those of the file format conversion method described in the aforementioned embodiment. Other technical features of the file format conversion device are the same as those disclosed in the aforementioned embodiment and are not further elaborated here.
[0068] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0069] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
[0070] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer program) stored thereon, wherein the computer-readable program instructions are used to execute the file format conversion method in the above embodiment.
[0071] The computer-readable storage medium provided herein may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems, or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including, but not limited to, wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0072] The computer-readable storage medium may be included in the file format conversion device; or may exist independently without being assembled into the file format conversion device.
[0073] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the file format conversion device, the file format conversion device: obtains a dictionary file according to the input file format and the output file format, and the dictionary file defines the keyword mapping relationship, parameter mapping relationship and data format description between the input file format and the output file format; obtains a keyword mapping table and a parameter mapping table according to the dictionary file, the keyword mapping relationship and the parameter mapping relationship; and obtains an output file according to the input file, the data format description, the keyword mapping table and the parameter mapping table.
[0074] Computer program code for performing the operations of the present application may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0075] 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 application. In this regard, each box in the flow chart or block diagram can represent a module, program segment or a part of code, and the module, program segment or a part of 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 than that 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 and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented by a dedicated hardware-based system that performs the specified function or operation, or can be implemented by a combination of dedicated hardware and computer instructions.
[0076] The modules described in the embodiments of the present application may be implemented in software or hardware, wherein the name of a module does not necessarily limit the unit itself.
[0077] The computer-readable storage medium provided in this application stores computer-readable program instructions (i.e., a computer program) for executing the aforementioned file format conversion method. This computer-readable storage medium can address the technical problem of improving the flexibility of file format conversion. Compared to the prior art, the beneficial effects of the computer-readable storage medium provided in this application are similar to those of the file format conversion method provided in the aforementioned embodiment and are not further elaborated here.
[0078] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned file format conversion method when executed by a processor.
[0079] The computer program product provided in this application can solve the technical problem of how to improve the flexibility of file format conversion. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as the beneficial effects of the file format conversion method provided in the above embodiment, and will not be repeated here.
[0080] The above description is only part of the embodiments of the present application and does not limit the patent scope of the present application. All equivalent structural transformations made by using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect application in other related technical fields are included in the patent protection scope of the present application.< / material>
Claims
1. A file format conversion method, It is characterized in that The method comprises: Acquire a dictionary file according to an input file format and an output file format, wherein the dictionary file defines a keyword mapping relationship, a parameter mapping relationship, and a data format description between the input file format and the output file format; Obtain a keyword mapping table and a parameter mapping table according to the dictionary file, the keyword mapping relationship and the parameter mapping relationship; An output file is obtained according to the input file, the data format description, the keyword mapping table and the parameter mapping table.
2. The method according to claim 1, It is characterized in that The step of obtaining a keyword mapping table and a parameter mapping table according to the dictionary file, the keyword mapping relationship and the parameter mapping relationship comprises: Read the dictionary file, and divide the read content into key-value pairs according to a preset identifier; A keyword mapping table and a parameter mapping table between the input file and the output file are constructed according to the keyword mapping relationship, the parameter mapping relationship and the key-value pair.
3. The method according to claim 1, It is characterized in that The step of obtaining the output file according to the input file, the data format description, the keyword mapping table and the parameter mapping table comprises: Read an input file, identify a first keyword in the input file, and record a first parameter under the first keyword; Obtaining, according to the first keyword, the first parameter, the data format description, the keyword mapping table, and the parameter mapping table, a second parameter and a second keyword corresponding to the first parameter corresponding to the first keyword; An output file is obtained according to the second keyword and the second parameter.
4. The method according to claim 3, It is characterized in that The step of obtaining the second parameter and the second keyword corresponding to the first parameter corresponding to the first keyword according to the first keyword, the first parameter, the data format description, the keyword mapping table and the parameter mapping table comprises: Traversing the first keyword, searching the keyword mapping table for corresponding second keyword content according to the currently traversed first keyword; Traversing the first parameter, and searching the parameter mapping table for a second parameter corresponding to the first parameter according to the currently traversed first parameter; A second keyword is constructed according to the data format description, the second keyword content and the second parameter.
5. The method according to claim 4, It is characterized in that After the step of traversing the first parameter and searching the parameter mapping table for a second parameter corresponding to the first parameter according to the currently traversed first parameter, the method further includes: When the second keyword content cannot be found, skip the first keyword currently traversed and continue to traverse the next first keyword; When the second parameter cannot be found, the traversal of the first parameter is stopped, the first keyword currently being traversed is skipped, and the traversal of the next first keyword is continued.
6. The method according to any one of claims 1 to 5, It is characterized in that The step of obtaining a dictionary file according to the input file format and the output file format comprises: When a dictionary file corresponding to the input file format and the output file format exists in the configuration file, obtaining the dictionary file from the configuration file; When the dictionary file does not exist in the configuration file, the dictionary file is written according to the input file format, the output file format, the dictionary file structure, the comment character, the line identifier, the keyword separator, the sub-object separator and the operator.
7. The method according to claim 6, It is characterized in that The step of writing the dictionary file according to the input file format, the output file format, the dictionary file structure, the annotation symbol, the line identifier, the keyword separator, the sub-object separator and the operator comprises: Obtaining keyword mapping rules and parameter mapping rules according to the input file format and the output file format; Defining the key-value pair structure and organization form of the dictionary file; Obtain a dictionary file structure according to the key-value pair structure and the organizational form; Select comment characters, line identifiers, keyword delimiters, sub-object delimiters, and operators; The dictionary file is written according to the keyword mapping rule, the parameter mapping rule, the dictionary file structure, the annotation symbol, the row identifier, the keyword separator, the sub-object separator, and the operator.
8. The method according to claim 3, It is characterized in that Before the step of identifying the first keyword in the input file, the method further includes: Detecting a file header, a separator, an identifier or an end mark of the input file to obtain a detection result; Obtaining a keyword format and a parameter format corresponding to the input file format; Verify the input file according to the keyword format and the parameter format to obtain a verification result; When there is no abnormality in the detection result or the verification result, continuing the step of identifying the first keyword in the input file; When there is an abnormality in the detection result or the verification result, the detection result and the verification result are recorded in an error log.
9. A file format conversion device, It is characterized in that The device comprises: A dictionary acquisition module, used to acquire a dictionary file according to an input file format and an output file format, wherein the dictionary file defines a keyword mapping relationship, a parameter mapping relationship and a data format description between the input file format and the output file format; A mapping table construction module, used to obtain a keyword mapping table and a parameter mapping table according to the dictionary file, the keyword mapping relationship and the parameter mapping relationship; The file output module is used to obtain an output file according to the input file, the data format description, the keyword mapping table and the parameter mapping table.
10. A storage medium, It is characterized in that The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the file format conversion method according to any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Data acquisition method and device
CN106649310A
Visual configuration editing method and device
CN106775725A
Data format conversion method and device
CN108446313A
Structured message self-adaptive conversion method and device
CN109889553A
Automatic format conversion
US20150081728A1
Cited By
Simulation model data format conversion method, electronic equipment, storage medium and device
CN119475735A
Model file conversion method and device based on CAD, electronic equipment and storage medium
CN120011310A
