ARXML file generation method and device, electronic equipment and program product

By using JSON skeleton and dynamic module generation technology in Excel to ARXML conversion, the problems of low automation and poor flexibility are solved, and efficient data conversion and simplified processing flow are achieved, suitable for diverse ARXML and Excel files.

CN118982001APending Publication Date: 2024-11-19BEIJING AUTOMOBILE RES GENERAL INST
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410862092.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-28
Publication Date
2024-11-19

AI Technical Summary

Technical Problem

The existing Excel to ARXML conversion technology has low automation, low development efficiency, and high cost, poor flexibility and limited application scope of commercial tools.

Method used

By receiving the Excel file to be converted, the data is loaded into the preset data structure, the JSON skeleton is used to add functions based on the dynamic module to generate the target JSON file, and parsing the target ARXML file, which improves the degree of automation and flexibility.

Benefits of technology

Simplifies the data processing process, reduces human errors, improves the conversion rate from Excel data to ARXML, and has higher scalability and flexibility, adapts to different types of ARXML files and Excel file formats.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118982001A_ABST
    Figure CN118982001A_ABST
Patent Text Reader

Abstract

The invention relates to an ARXML file generation method and device, electronic equipment and a program product, and the method comprises the steps: receiving a to-be-converted Excel file, loading data in the to-be-converted Excel file into a preset data structure, and obtaining to-be-converted parameters; based on the to-be-converted parameters and a preset JSON skeleton, a preset dynamic module is utilized to add a function to generate a target JSON file; and analyzing the target JSON file to obtain a plurality of key value pairs, converting each key value pair to obtain a plurality of XML elements, and generating a target ARXML file based on the plurality of XML elements. Therefore, the problems that the conversion function from the Excel data to the ARXML is limited or exclusive, high in cost, low in flexibility and the like are solved, the automation degree of data conversion is improved, human errors are reduced, higher expandability and flexibility are achieved, and the conversion rate from the Excel data to the ARXML is effectively increased.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to an ARXML file generation method, device, electronic device and program product. Background Art

[0002] ARXML (AUTOSAR XML) is part of the AUTOSAR (Automotive Open System Architecture) standard. It is used to describe various elements including hardware, software, communication, and system configuration. It is an indispensable part of ECU (Electronic Control Unit) development.

[0003] In actual engineering practice, a lot of data and configurations are first edited and maintained in Excel tables. Excel provides an intuitive, flexible and well-known interface, which greatly facilitates the management and operation of data compared to the complex manual configuration of parameters in the graphical interface of a specific tool. Engineers can easily add, modify, delete or copy data in batches in Excel, especially when dealing with large amounts of data. Therefore, an effective mechanism is needed to convert these data maintained in Excel into ARXML format for use by the AUTOSAR tool chain.

[0004] At present, although there is no complete commercial-grade source code for direct comparison of Excel to ARXML conversion technology, it is understood that the Excel to ARXML conversion in related technologies usually uses the method of directly operating to generate XML, such as using the SubElement() function of the Python built-in xml.etree.ElementTree library to manually create XML tags one by one, including the processing of static and dynamic parts. However, the degree of automation and development efficiency of this method are low, and the accuracy needs to be improved.

[0005] In the related technology, commercial software provides the function of converting Excel data to ARXML, but these tools are usually paid and have certain limitations or proprietary features. In particular, these tools cannot fully adapt when processing a wide variety of ARXML files with specific structures and uses, as well as Excel files with various formats. This limits their scope of application and needs to be solved urgently. Summary of the invention

[0006] The present application provides an ARXML file generation method, device, electronic device and program product to solve the problems of limitation or proprietary nature, high cost and low flexibility of the conversion function from Excel data to ARXML in the related art, improve the automation of data conversion, simplify the data processing process, reduce the occurrence of human errors, have higher scalability and flexibility, and effectively improve the conversion rate from Excel data to ARXML.

[0007] The first aspect of the present application provides an ARXML file generation method, comprising the following steps:

[0008] Receive an Excel file to be converted, load the data in the Excel file to be converted into a preset data structure, and obtain parameters to be converted;

[0009] Based on the parameters to be converted and the preset JSON skeleton, a preset dynamic module adding function is used to generate a target JSON file;

[0010] The target JSON file is parsed to obtain a plurality of key-value pairs, each key-value pair is converted to obtain a plurality of XML elements, and a target ARXML file is generated based on the plurality of XML elements.

[0011] Optionally, in some embodiments, before generating the target JSON file using the preset dynamic module adding function based on the parameters to be converted and the preset JSON skeleton, the method further includes:

[0012] Obtain a reference ARXML file, and convert the reference ARXML file to obtain a JSON structure reference file;

[0013] Parse the JSON structure reference file to obtain multiple static data, multiple empty dictionaries and reserved keys of each empty dictionary;

[0014] The preset JSON skeleton is generated according to the JSON structure reference file, the multiple static data, the multiple empty dictionaries and the reserved keys of each empty dictionary.

[0015] Optionally, in some embodiments, generating a target JSON file based on the parameters to be converted and a preset JSON skeleton using a preset dynamic module adding function includes:

[0016] Processing the parameters to be converted by a preset dynamic JSON information creation function to obtain list data, wherein the list data includes at least one dictionary element, and the dictionary element includes a key of the dictionary element and a value of the dictionary element;

[0017] Based on the reserved keys of all empty dictionaries, determine the current reserved key to be compared according to the preset key sequence, and judge whether the current reserved key to be compared is consistent with the key of the dictionary element;

[0018] If the current reserved key to be compared is consistent with the key of the dictionary element, updating the current empty dictionary based on the key of the dictionary element corresponding to the dictionary element and the value of the dictionary element;

[0019] Repeat the steps of determining the current reserved key to be compared based on the reserved keys of all empty dictionaries according to the preset key sequence, and determining whether the new reserved key to be compared is consistent with the key of the dictionary element until the list data is an empty value.

[0020] Optionally, in some embodiments, converting each key-value pair to obtain a plurality of XML elements, and generating a target ARXML file based on the plurality of XML elements includes:

[0021] Determine the attribute name of the tag of the current XML element according to the key of the current key value, and determine the attribute value of the current XML element according to the value of the current key value;

[0022] The key of the specified key-value pair is used as the root element. Based on the root element, the steps of determining the attribute name of the tag of the current XML element according to the key of the current key value and determining the attribute value of the current XML element according to the value of the current key value are repeated for each key-value pair to obtain multiple XML elements, and the multiple XML elements are saved to the target ARXML file.

[0023] A second aspect of the present application provides an ARXML file generation device, including:

[0024] A loading module, used for receiving an Excel file to be converted, loading the data in the Excel file to be converted into a preset data structure, and obtaining parameters to be converted;

[0025] Creating a module for generating a target JSON file by using a preset dynamic module adding function based on the parameters to be converted and a preset JSON skeleton;

[0026] The generation module is used to parse the target JSON file to obtain multiple key-value pairs, convert each key-value pair to obtain multiple XML elements, and generate a target ARXML file based on the multiple XML elements.

[0027] Optionally, in some embodiments, before generating the target JSON file using the preset dynamic module adding function based on the parameters to be converted and the preset JSON skeleton, the creation module is further used to:

[0028] Obtain a reference ARXML file, and convert the reference ARXML file to obtain a JSON structure reference file;

[0029] Parse the JSON structure reference file to obtain multiple static data, multiple empty dictionaries and reserved keys of each empty dictionary;

[0030] The preset JSON skeleton is generated according to the JSON structure reference file, the multiple static data, the multiple empty dictionaries and the reserved keys of each empty dictionary.

[0031] Optionally, in some embodiments, the creation module is specifically used to:

[0032] Processing the parameters to be converted by a preset dynamic JSON information creation function to obtain list data, wherein the list data includes at least one dictionary element, and the dictionary element includes a key of the dictionary element and a value of the dictionary element;

[0033] Based on the reserved keys of all empty dictionaries, determine the current reserved key to be compared according to the preset key sequence, and judge whether the current reserved key to be compared is consistent with the key of the dictionary element;

[0034] When the current reserved key to be compared is consistent with the key of the dictionary element, updating the current empty dictionary based on the key of the dictionary element corresponding to the dictionary element and the value of the dictionary element;

[0035] Repeat the steps of determining the current reserved key to be compared based on the reserved keys of all empty dictionaries according to the preset key sequence, and determining whether the new reserved key to be compared is consistent with the key of the dictionary element until the list data is an empty value.

[0036] Optionally, in some embodiments, the generating module is specifically used to:

[0037] Determine the attribute name of the tag of the current XML element according to the key of the current key value, and determine the attribute value of the current XML element according to the value of the current key value;

[0038] The key of the specified key-value pair is used as the root element. Based on the root element, the steps of determining the attribute name of the tag of the current XML element according to the key of the current key value and determining the attribute value of the current XML element according to the value of the current key value are repeated for each key-value pair to obtain multiple XML elements, and the multiple XML elements are saved to the target ARXML file.

[0039] The third aspect of the present application provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the ARXML file generation method as described in the above embodiment.

[0040] The fourth aspect of the present application provides a computer program product, including a computer program, which is executed to implement the ARXML file generation method as described in the above embodiment.

[0041] Therefore, the present application receives the Excel file to be converted, loads the data in the Excel file to be converted into a preset data structure, obtains the parameters to be converted, generates the target JSON file based on the parameters to be converted and the preset JSON skeleton, uses the preset dynamic module to add functions, parses the target JSON file, obtains multiple key-value pairs, and converts each key-value pair to obtain multiple XML elements, and generates the target ARXML file based on the multiple XML elements. Therefore, the problems in the related art that the conversion function from Excel data to ARXML is limited or proprietary, high cost and low flexibility are solved, the automation of data conversion is improved, the process of data processing is simplified, the occurrence of human errors is reduced, it has higher scalability and flexibility, and effectively improves the conversion rate from Excel data to ARXML.

[0042] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:

[0044] Figure 1 A flowchart of an ARXML file generation method provided according to an embodiment of the present application;

[0045] Figure 2 It is a block diagram of an ARXML file generation device provided according to an embodiment of the present application;

[0046] Figure 3 A block diagram of an electronic device provided according to an embodiment of the present application. DETAILED DESCRIPTION

[0047] Embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.

[0048] The ARXML file generation method, device, electronic device and program product of the embodiment of the present application are described below with reference to the accompanying drawings. In view of the problems mentioned in the above background technology that the conversion function from Excel data to ARXML has limitations or exclusivity, high cost and low flexibility, the present application provides an ARXML file generation method, in which an Excel file to be converted is received, and the data in the Excel file to be converted is loaded into a preset data structure to obtain parameters to be converted; based on the parameters to be converted and the preset JSON skeleton, a preset dynamic module is used to add a function to generate a target JSON file; the target JSON file is parsed to obtain multiple key-value pairs, and each key-value pair is converted to obtain multiple XML elements, and a target ARXML file is generated based on multiple XML elements. Thus, the problems of limitations or exclusivity, high cost and low flexibility in the conversion function from Excel data to ARXML are solved, the degree of automation of data conversion is improved, the process of data processing is simplified, the occurrence of human errors is reduced, it has higher scalability and flexibility, and effectively improves the conversion rate from Excel data to ARXML.

[0049] Specifically, Figure 1 A flowchart of an ARXML file generation method provided in an embodiment of the present application.

[0050] like Figure 1 As shown, the ARXML file generation method includes the following steps:

[0051] In step S101, an Excel file to be converted is received, and data in the Excel file to be converted is loaded into a preset data structure to obtain parameters to be converted.

[0052] Among them, the preset data structure of the embodiment of the present application is a table data structure, and the parameter to be converted is a list of one or more dictionary elements.

[0053] It is understandable that there are many types of ARXML files and each file has its own specific structure and purpose. Therefore, before developing a specific Excel to ARXML conversion tool, in addition to the Excel file used as the tool input, the embodiment of the present application also needs to obtain a sample of the target ARXML file. This file will serve as a reference or template to help those skilled in the art understand the specific format and structure of the ARXML file.

[0054] In actual engineering practice, many data and configurations are first edited and maintained in the Eecel table. The Excel file to be converted in the embodiment of the present application is an Excel file used as the tool input. Based on the Excel file to be converted, the present application can develop a conversion tool from a specific Excel file to ARXML.

[0055] Specifically, the embodiment of the present application extracts the data of the Excel file to be converted through the pandas library, and the data is a DataFrame (a tabular data structure), that is, the parameters to be converted in the embodiment of the present application.

[0056] It should be noted that the embodiment of the present application creates a preset JSON skeleton. After receiving the Excel file to be converted, different modules are divided based on the Excel file to be converted. The embodiment of the present application will receive the created JSON format data and the data (DataFrame) in Excel required by the current module as parameters to be converted.

[0057] In step S102, based on the parameters to be converted and the preset JSON skeleton, a target JSON file is generated using a preset dynamic module adding function.

[0058] Among them, the preset JSON skeleton of the embodiment of the present application is the static part in the JSON data.

[0059] It can be understood that the present application uses JSON as a transit format to process data, first converting the data into JSON format, and then converting the JSON data into ARXML. Therefore, the embodiment of the present application needs to first create a target JSON file, and the target JSON file of the embodiment of the present application is used for subsequent JSON data conversion into ARXML.

[0060] Optionally, in some embodiments, before generating a target JSON file by adding a function using a preset dynamic module based on the parameters to be converted and the preset JSON skeleton, it also includes: obtaining a reference ARXML file, converting the reference ARXML file to obtain a JSON structure reference file; parsing the JSON structure reference file to obtain multiple static data, multiple empty dictionaries and reserved keys for each empty dictionary; generating a preset JSON skeleton according to the JSON structure reference file, multiple static data, multiple empty dictionaries and the reserved keys for each empty dictionary.

[0061] It can be understood that the embodiment of the present application uses a python library named xmltodict to convert an existing reference ARXML file into JSON format, which is used as a structural reference for the conversion, i.e., the JSON structure reference file of the embodiment of the present application, thereby generating a structural representation of the ARXML file, providing a basis for the next step of creating a JSON skeleton.

[0062] For example, the embodiment of the present application uses the xmltodict library to parse the XML data of ARXML into a Python dictionary. The embodiment of the present application can use the xmltodict.parse() function, which is used to parse XML data, takes XML data as input, and returns a dictionary, in which XML tags are converted to dictionary keys, and the text content and other attributes within the XML tags are appropriately stored in the dictionary values. Thus, the embodiment of the present application can convert the tags in the reference ARXML file into dictionary keys, the attributes of the tags are converted to keys starting with @, and the text content of the tags is stored under the #text key.

[0063] Furthermore, after obtaining the JSON structure reference file data, the embodiment of the present application needs to extract the static part as the skeleton, that is, the preset JSON skeleton of the embodiment of the present application. Although the preset JSON skeleton looks the same as the JSON format, the data type is actually a collection of Python dictionary (dict) and list (list) structures.

[0064] It should be noted that in order to keep the description concise, the term "JSON" will continue to be used to refer to these data structures in the following description. Until the skeleton is filled in, these structures do not actually exist in the form of JSON files, but are processed and operated as Python internal data structures.

[0065] The dynamic part in the preset JSON skeleton of the embodiment of the present application is reserved in the form of an empty dictionary. For example, "DATA-TYPE-MAPS":{} in the skeleton creation function is represented as an empty dictionary in the data structure. In subsequent steps, this skeleton will be used to fill in the data dynamically generated according to Excel until a complete data structure is formed. Finally, this data structure can be converted to JSON format for storage and comparison, and as input for the subsequent JSON to ARXML module.

[0066] Optionally, in some embodiments, based on the parameters to be converted and the preset JSON skeleton, a preset dynamic module is used to add a function to generate a target JSON file, including: processing the parameters to be converted by a preset function to create dynamic JSON information to obtain list data, wherein the list data includes at least one dictionary element, and the dictionary element includes the key of the dictionary element and the value of the dictionary element; based on the reserved keys of all empty dictionaries, determining the current reserved key to be compared according to a preset key sequence, and judging whether the current reserved key to be compared is consistent with the key of the dictionary element; if the current reserved key to be compared is consistent with the key of the dictionary element, updating the current empty dictionary based on the key of the dictionary element corresponding to the dictionary element and the value of the dictionary element; repeating the steps of determining the current reserved key to be compared based on the reserved keys of all empty dictionaries according to the preset key sequence, and judging whether the new reserved key to be compared is consistent with the key of the dictionary element, until the list data is an empty value.

[0067] It is understandable that the present embodiment uses the pandas library to process Excel data and generates dynamic JSON data in modules, which are then added to the skeleton to form a complete JSON structure. After completion, the present embodiment needs to compare this JSON file with the JSON converted from the reference ARXML file to see if it is consistent.

[0068] Specifically, an embodiment of the present application creates a function from Excel to JSON. The embodiment of the present application defines a conversion function xlsx_to_json() from Excel to JSON. The conversion function xlsx_to_json() defines two parameters, namely the Excel file address to be converted and the JSON file address. The above-mentioned target JSON file is read, and the function add_DataTypeMappingSets(data, df_data_type) is added according to the preset dynamic module. The parameter data in the preset dynamic module adding function is the target JSON file, and df_data_type is the parameter to be converted.

[0069] Thus, the embodiment of the present application adds a function through a preset dynamic module, receives the currently created JSON format data, and the data (DataFrame) in Excel required by this module as parameters. The function first calls the function for creating dynamic JSON information, that is, the preset function for creating dynamic JSON information in the embodiment of the present application, and the JSON form returned by the preset function for creating dynamic JSON information may contain a list of one or more dictionary elements.

[0070] Furthermore, the embodiment of the present application starts from the root node of the JSON skeleton and routes to the key of the reserved position in the skeleton. The embodiment of the present application needs to add a key-value pair to the value (blank dictionary) corresponding to this key. If the value here contains multiple elements (dictionary), it is a list, and if there is only one dictionary element, then the value is this dictionary. For example, in the above embodiment, the skeleton reserves "DATA-TYPE-MAPS":{}, and what needs to be added is a key-value pair with "DATA-TYPE-MAP" as the key.

[0071] It should be noted that the embodiment of the present application creates a dictionary structure for each Excel data type. Each dictionary to be generated still contains many static structures. The embodiment of the present application only needs to insert the data read from the table into a specific position in the dictionary structure.

[0072] In other embodiments, the present application can directly use Python dictionary lists without generating JSON files. Specifically, the Excel to JSON module first builds the Python dictionary list structure and then serializes it into a JSON file as output, and this JSON file will be used as the input of the subsequent JSON to ARXML module. However, in actual applications, it is entirely possible to directly use the Python dictionary list structure for data transfer without generating a JSON file. This method can reduce file I / O (Input / Output) operations, thereby partially improving processing efficiency. The main purpose of generating JSON files during the development and testing phases of the present application is to facilitate viewing and comparative reference, to help those skilled in the art understand the data structure and conversion results more clearly. During actual deployment and operation, these dictionary list structures can be processed entirely in memory to improve the speed and efficiency of overall data processing.

[0073] Therefore, this application automates most of the data conversion process by adopting JSON as the transit format. This approach not only significantly improves the overall efficiency, but also simplifies the creation process of XML tags.

[0074] In step S103, the target JSON file is parsed to obtain a plurality of key-value pairs, each key-value pair is converted to obtain a plurality of XML elements, and a target ARXML file is generated based on the plurality of XML elements.

[0075] It is understandable that after parsing the target JSON file, the embodiment of the present application obtains multiple key-value pairs, which are then converted to obtain XML elements, and the target ARXML file is generated based on the XML elements. Thus, the complete JSON data is converted into the ARXML format through a fixed conversion logic code.

[0076] Based on the above embodiment, it can be understood that there is a direct mapping relationship between ARXML and the JSON converted by the xmltodict library. The attribute name of each tag in ARXML is mapped to a key starting with "@" in JSON, and the value of the attribute is the value of the key starting with "@". For a tag containing at least one attribute, the content of the tag is the value of the "#text" key in JSON.

[0077] Specifically, the above conversion process can be implemented using Python's xml.etree.ElementTree library, which provides powerful functions for creating and manipulating XML files, making the conversion from JSON to XML feasible and efficient.

[0078] Therefore, compared with the methods in the related art, the present application shows higher scalability and flexibility when it is necessary to process different types of ARXML files. The embodiment of the present application only needs to adjust the dynamic part of processing Excel to JSON to cope with different data structures without rewriting the entire conversion logic. In addition, adding dynamic data in JSON is simpler and faster than in XML. JSON's data structure is more flexible, and adding or modifying data usually only requires simple key-value operations, while XML's data operations are usually more complicated, especially when it comes to modifying nested elements or attributes.

[0079] Optionally, in some embodiments, each key-value pair is converted to obtain multiple XML elements, and a target ARXML file is generated based on the multiple XML elements, including: determining the attribute name of the tag of the current XML element according to the key of the current key value, and determining the attribute value of the current XML element according to the value of the current key value; using the key of the specified key-value pair as the root element, and based on the root element, repeating the steps of determining the attribute name of the tag of the current XML element according to the key of the current key value, and determining the attribute value of the current XML element according to the value of the current key value for each key-value pair to obtain multiple XML elements, and saving the multiple XML elements to the target ARXML file.

[0080] It can be understood that the embodiment of the present application creates a json2xml() function, which recursively traverses the JSON data and converts it into corresponding XML elements. For each key-value pair in the JSON, the XML element is created or set accordingly according to the type of the key (attribute, text or sub-element). Therefore, the embodiment of the present application can use the json2xml() function to automatically complete the creation of XML tags through recursive calls, without manually encoding each tag, thereby greatly improving the efficiency of data processing.

[0081] Furthermore, the embodiment of the present application creates a json_to_arxml() function, which first reads the JSON file and parses it into a Python dictionary. Then, the first key of the JSON data is used as the root element, and then the JSON data is recursively converted into an XML element and attached to the root element. Then, the generated XML string is parsed and formatted using the XMLParser of the lxml library to ensure correct indentation and structure. Finally, the formatted XML data is saved as the target ARXML file.

[0082] In other embodiments, the present application can completely use other libraries such as lxml to implement the conversion process from JSON to ARXML. Specifically, the currently implemented ARXML construction mainly relies on the xml.etree.ElementTree library built into Python. However, a similar data conversion process can be completed by using advanced external libraries such as lxml. lxml provides more efficient processing speed and wider functional support, and is particularly suitable for processing complex XML structures. This alternative implementation may further improve data processing efficiency, although some additional development work is required to adapt the existing data processing logic. In addition, similar to the xmltodict library mentioned in From ARXML to JSON, there is also a library (dicttoxml) that directly converts dictionary structures into XML, but considering the flexibility and controllability of the key step of generating ARXML, the present application chooses the above-mentioned handwritten code form instead of directly using the dicttoxml library.

[0083] It should be noted that the embodiment of the present application can process multiple module creation processes in the Excel to JSON process in parallel. Specifically, for complex data structures, multiple modules are currently used to add dynamic JSON structures. The module added by the present application for each dynamic JSON structure can also be divided into two parts, namely, JSON structure creation and adding the created JSON structure to the skeleton. All JSON structure creation parts are independent of each other, except that the same DataFrame is sometimes read, so they are thread-safe. Therefore, in order to increase the conversion rate, the JSON structure creation parts of all modules can be processed in parallel by multithreading, and then they are sequentially added to the JSON skeleton. Those skilled in the art have not yet encountered big data processing needs, so this method has not yet been used.

[0084] Finally, the embodiment of the present application can call two functions from Excel to JSON and from JSON to ARXML to realize the complete conversion process. Therefore, compared with the method of manually creating XML tags in the related art, especially when processing ARXML files with complex data structures and multi-layer nesting, the possibility of errors is higher, and these errors may be caused by negligence in the manual coding process, such as spelling errors of tags, incorrect organization of structures, or incorrect settings of attributes. However, the conversion method from JSON to ARXML adopted in the present application standardizes the entire data processing process, and greatly reduces the need for manual intervention by using a predefined JSON structure as a blueprint for conversion, thereby reducing the occurrence of human errors. In addition, this method allows for a more thorough inspection and verification of JSON data before conversion to XML, further improving data accuracy. In addition, the degree of automation of the method provided by the present application is high, and its error-reducing process can significantly save time and resources, thereby bringing economic benefits, and higher accuracy and efficiency mean less rework and modification, further reducing costs.

[0085] Based on the above embodiments, it can be understood that the present application uses JSON as a transit format to process data, which improves the adaptability and flexibility to different Excel tables and ARXML file formats. By first converting the data into JSON format and then converting JSON into ARXML, the present application simplifies the data processing and mapping logic, especially for data containing complex structures and multi-layer nesting.

[0086] The embodiment of the present application provides a set of fixed logic codes to accurately convert JSON data into ARXML format. The standardization and consistency of this conversion logic greatly simplifies the customized programming requirements to adapt to different ARXML structures, and provides a solid foundation for processing a variety of ARXML files. The core advantage of the embodiment of the present application lies in its significant scalability. By simply adjusting the dynamic part of the code that processes Excel to JSON, it can easily adapt to a variety of Excel data sources and ARXML file formats. This not only improves the scope of application and flexibility of the tool, but also ensures efficiency and accuracy when facing different data processing requirements.

[0087] In addition, the present application reduces the need for manual data processing through an automated data conversion process, while improving the accuracy and efficiency of data processing. It also avoids the situation where each XML tag needs to be manually created using the xml.etree.ElementTree library during the data conversion process by using a large number of predefined static JSON structures. This not only speeds up data processing, but also reduces the risk of inaccurate data caused by manual coding errors. This is particularly important for the development of automotive electronic systems that need to process large amounts of data. Therefore, the ARXML file generation method of the present application can convert Excel data into ARXML format, which is suitable for processing complex automotive electronic system data.

[0088] It should be noted that, although there is no direct test comparison for the same ARXML file, there is no difference between the Excel to ARXML conversion rate of this application and the related technology. However, after testing, the JSON to ARXML conversion speed in this application can still be completed in a very short time for samples with large amounts of data (the ARXML of the test sample has 174166 rows). Therefore, even if the use of JSON as a transfer increases the conversion steps, there is no need to worry about a decrease in the conversion rate. In addition, in the Excel to JSON conversion step, this application uses a large number of static JSON structures (which do not change with the data in Excel), which will also reduce the conversion time to a certain extent.

[0089] According to the ARXML file generation method proposed in the embodiment of the present application, by receiving the Excel file to be converted, the data in the Excel file to be converted is loaded into a preset data structure to obtain the parameters to be converted, based on the parameters to be converted and the preset JSON skeleton, a preset dynamic module is used to add a function to generate a target JSON file, the target JSON file is parsed to obtain multiple key-value pairs, and each key-value pair is converted to obtain multiple XML elements, and a target ARXML file is generated based on multiple XML elements. Thus, the problems of the conversion function from Excel data to ARXML in the related art, such as limitation or proprietary, high cost and low flexibility, are solved, the automation of data conversion is improved, the process of data processing is simplified, the occurrence of human errors is reduced, it has higher scalability and flexibility, and effectively improves the conversion rate from Excel data to ARXML.

[0090] Next, the ARXML file generation device proposed in accordance with the embodiment of the present application is described with reference to the accompanying drawings.

[0091] Figure 2 It is a block diagram of an ARXML file generating device according to an embodiment of the present application.

[0092] like Figure 2As shown, the ARXML file generating device 10 includes: a loading module 100 , a creating module 200 and a generating module 300 .

[0093] Specifically, the loading module 100 is used to receive the Excel file to be converted, load the data in the Excel file to be converted into a preset data structure, and obtain the parameters to be converted; the creation module 200 is used to generate the target JSON file based on the parameters to be converted and the preset JSON skeleton, using the preset dynamic module to add functions; the generation module 300 is used to parse the target JSON file to obtain multiple key-value pairs, and convert each key-value pair to obtain multiple XML elements, and generate the target ARXML file based on the multiple XML elements.

[0094] Optionally, in some embodiments, before generating a target JSON file by using a preset dynamic module to add a function based on the parameters to be converted and the preset JSON skeleton, a module 200 is created and is also used to: obtain a reference ARXML file, convert the reference ARXML file to obtain a JSON structure reference file; parse the JSON structure reference file to obtain multiple static data, multiple empty dictionaries and reserved keys for each empty dictionary; generate a preset JSON skeleton according to the JSON structure reference file, multiple static data, multiple empty dictionaries and the reserved keys for each empty dictionary.

[0095] Optionally, in some embodiments, the creation module 200 is specifically used to: process the parameters to be converted through a preset function for creating dynamic JSON information to obtain list data, wherein the list data includes at least one dictionary element, and the dictionary element includes the key of the dictionary element and the value of the dictionary element; based on the reserved keys of all empty dictionaries, determine the current reserved key to be compared according to a preset key sequence, and judge whether the current reserved key to be compared is consistent with the key of the dictionary element; when the current reserved key to be compared is consistent with the key of the dictionary element, update the current empty dictionary based on the key of the dictionary element corresponding to the dictionary element and the value of the dictionary element; repeat the steps of determining the current reserved key to be compared based on the reserved keys of all empty dictionaries according to the preset key sequence, and based on whether the new reserved key to be compared is consistent with the key of the dictionary element, until the list data is an empty value.

[0096] Optionally, in some embodiments, the generation module 300 is specifically used to: determine the attribute name of the tag of the current XML element according to the key of the current key value, and determine the attribute value of the current XML element according to the value of the current key value; use the key of the specified key-value pair as the root element, and based on the root element, repeat the steps of determining the attribute name of the tag of the current XML element according to the key of the current key value, and determining the attribute value of the current XML element according to the value of the current key value for each key-value pair, to obtain multiple XML elements, and save the multiple XML elements to the target ARXML file.

[0097] It should be noted that the aforementioned explanation of the ARXML file generation method embodiment is also applicable to the ARXML file generation device of this embodiment, and will not be repeated here.

[0098] According to the ARXML file generation device proposed in the embodiment of the present application, by receiving the Excel file to be converted, the data in the Excel file to be converted is loaded into a preset data structure to obtain the parameters to be converted, based on the parameters to be converted and the preset JSON skeleton, a preset dynamic module is used to add a function to generate a target JSON file, the target JSON file is parsed to obtain multiple key-value pairs, and each key-value pair is converted to obtain multiple XML elements, and a target ARXML file is generated based on the multiple XML elements. Thus, the problems of the conversion function from Excel data to ARXML in the related art, such as limitation or proprietary, high cost and low flexibility, are solved, the automation degree of data conversion is improved, the process of data processing is simplified, the occurrence of human errors is reduced, it has higher scalability and flexibility, and effectively improves the conversion rate from Excel data to ARXML.

[0099] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device may include:

[0100] A memory 301 , a processor 302 , and a computer program stored in the memory 301 and executable on the processor 302 .

[0101] When the processor 302 executes the program, the ARXML file generation method provided in the above embodiment is implemented.

[0102] Furthermore, the electronic device further comprises:

[0103] The communication interface 303 is used for communication between the memory 301 and the processor 302 .

[0104] The memory 301 is used to store computer programs that can be run on the processor 302 .

[0105] The memory 301 may include a high-speed RAM (Random Access Memory) memory, and may also include a non-volatile memory, such as at least one disk memory.

[0106] If the memory 301, the processor 302 and the communication interface 303 are implemented independently, the communication interface 303, the memory 301 and the processor 302 can be connected to each other through a bus and communicate with each other. The bus can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0107] Optionally, in a specific implementation, if the memory 301, the processor 302 and the communication interface 303 are integrated on a chip, the memory 301, the processor 302 and the communication interface 303 can communicate with each other through an internal interface.

[0108] The processor 302 may be a CPU (Central Processing Unit), or an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present application.

[0109] An embodiment of the present application also provides a computer program product, including a computer program, which implements the above ARXML file generation method when executed.

[0110] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms are not necessarily directed to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or N embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0111] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0112] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or N executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.

[0113] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above embodiment, the N steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one or a combination of multiple of the following technologies known in the art: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array, a field programmable gate array, etc.

[0114] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.

[0115] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present application.

Claims

1. A method for generating an ARXML file, It is characterized in that The following steps are involved: Receive an Excel file to be converted, load the data in the Excel file to be converted into a preset data structure, and obtain parameters to be converted; Based on the parameters to be converted and the preset JSON skeleton, a preset dynamic module adding function is used to generate a target JSON file; The target JSON file is parsed to obtain a plurality of key-value pairs, each key-value pair is converted to obtain a plurality of XML elements, and a target ARXML file is generated based on the plurality of XML elements.

2. The method according to claim 1, It is characterized in that Before generating the target JSON file by using the preset dynamic module adding function based on the parameters to be converted and the preset JSON skeleton, the method further includes: Obtain a reference ARXML file, and convert the reference ARXML file to obtain a JSON structure reference file; Parse the JSON structure reference file to obtain multiple static data, multiple empty dictionaries and reserved keys of each empty dictionary; The preset JSON skeleton is generated according to the JSON structure reference file, the multiple static data, the multiple empty dictionaries and the reserved keys of each empty dictionary.

3. The method according to claim 2, It is characterized in that The method of generating a target JSON file based on the parameters to be converted and the preset JSON skeleton using a preset dynamic module adding function includes: Processing the parameters to be converted by a preset dynamic JSON information creation function to obtain list data, wherein the list data includes at least one dictionary element, and the dictionary element includes a key of the dictionary element and a value of the dictionary element; Based on the reserved keys of all empty dictionaries, determine the current reserved key to be compared according to the preset key sequence, and judge whether the current reserved key to be compared is consistent with the key of the dictionary element; If the current reserved key to be compared is consistent with the key of the dictionary element, updating the current empty dictionary based on the key of the dictionary element corresponding to the dictionary element and the value of the dictionary element; Repeat the steps of determining the current reserved key to be compared based on the reserved keys of all empty dictionaries according to the preset key sequence, and determining whether the new reserved key to be compared is consistent with the key of the dictionary element until the list data is an empty value.

4. The method according to claim 3, It is characterized in that The converting each key-value pair to obtain a plurality of XML elements, and generating a target ARXML file based on the plurality of XML elements, includes: Determine the attribute name of the tag of the current XML element according to the key of the current key value, and determine the attribute value of the current XML element according to the value of the current key value; The key of the specified key-value pair is used as the root element. Based on the root element, the steps of determining the attribute name of the tag of the current XML element according to the key of the current key value and determining the attribute value of the current XML element according to the value of the current key value are repeated for each key-value pair to obtain multiple XML elements, and the multiple XML elements are saved to the target ARXML file.

5. An ARXML file generation device, It is characterized in that include: A loading module, used for receiving an Excel file to be converted, loading the data in the Excel file to be converted into a preset data structure, and obtaining parameters to be converted; Create a module for generating a target JSON file based on the parameters to be converted and the preset JSON skeleton by using a preset dynamic module adding function; The generation module is used to parse the target JSON file to obtain multiple key-value pairs, convert each key-value pair to obtain multiple XML elements, and generate a target ARXML file based on the multiple XML elements.

6. The device according to claim 5, It is characterized in that Before generating the target JSON file by using the preset dynamic module adding function based on the parameters to be converted and the preset JSON skeleton, the creation module is further used to: Obtain a reference ARXML file, and convert the reference ARXML file to obtain a JSON structure reference file; Parse the JSON structure reference file to obtain multiple static data, multiple empty dictionaries and reserved keys of each empty dictionary; The preset JSON skeleton is generated according to the JSON structure reference file, the multiple static data, the multiple empty dictionaries and the reserved keys of each empty dictionary.

7. The device according to claim 6, It is characterized in that The creation module is specifically used for: Processing the parameters to be converted by a preset dynamic JSON information creation function to obtain list data, wherein the list data includes at least one dictionary element, and the dictionary element includes a key of the dictionary element and a value of the dictionary element; Based on the reserved keys of all empty dictionaries, determine the current reserved key to be compared according to the preset key sequence, and judge whether the current reserved key to be compared is consistent with the key of the dictionary element; When the current reserved key to be compared is consistent with the key of the dictionary element, updating the current empty dictionary based on the key of the dictionary element corresponding to the dictionary element and the value of the dictionary element; Repeat the steps of determining the current reserved key to be compared based on the reserved keys of all empty dictionaries according to the preset key sequence, and determining whether the new reserved key to be compared is consistent with the key of the dictionary element until the list data is an empty value.

8. The device according to claim 7, It is characterized in that The generation module is specifically used for: Determine the attribute name of the tag of the current XML element according to the key of the current key value, and determine the attribute value of the current XML element according to the value of the current key value; The key of the specified key-value pair is used as the root element. Based on the root element, the steps of determining the attribute name of the tag of the current XML element according to the key of the current key value and determining the attribute value of the current XML element according to the value of the current key value are repeated for each key-value pair to obtain multiple XML elements, and the multiple XML elements are saved to the target ARXML file.

9. An electronic device, It is characterized in that include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the ARXML file generation method according to any one of claims 1 to 4.

10. A computer program product comprising a computer program, It is characterized in that The computer program is executed to implement the ARXML file generation method according to any one of claims 1 to 4.