CN111062189B - Data analysis method and device and electronic equipment - Google Patents

Data analysis method and device and electronic equipment Download PDF

Info

Publication number
CN111062189B
CN111062189B CN201811204736.5A CN201811204736A CN111062189B CN 111062189 B CN111062189 B CN 111062189B CN 201811204736 A CN201811204736 A CN 201811204736A CN 111062189 B CN111062189 B CN 111062189B
Authority
CN
China
Prior art keywords
source
field position
data
target
format
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811204736.5A
Other languages
Chinese (zh)
Other versions
CN111062189A (en
Inventor
刘天宇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hitevision Co Ltd
Original Assignee
Hitevision Co Ltd
Filing date
Publication date
Application filed by Hitevision Co Ltd filed Critical Hitevision Co Ltd
Priority to CN201811204736.5A priority Critical patent/CN111062189B/en
Publication of CN111062189A publication Critical patent/CN111062189A/en
Application granted granted Critical
Publication of CN111062189B publication Critical patent/CN111062189B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention discloses a data analysis method and device and electronic equipment, comprising the following steps: establishing a data format corresponding table, wherein the data format corresponding table comprises a corresponding relation between a source field position of a source data format and a target field position of a target data format; reading a source data file in a source data format, and acquiring the source field position and the source field content corresponding to the source field position from the source data file; searching the data format corresponding table according to the source field position, and acquiring a target field position corresponding to the source field position; and storing the source field content in the target field position as target field content corresponding to the target field position. The method and the device can realize the rapid conversion and storage from Json format data to XML format data, are convenient to maintain and reduce the complexity of the program.

Description

Data analysis method and device and electronic equipment
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a data analysis method and apparatus, and an electronic device.
Background
The existing method for converting Json format data into XML format data generally comprises the steps of firstly reading the Json data at the corresponding position in the Json file, determining the corresponding position in the XML file, and then storing the Json data at the corresponding position in the XML file.
Disclosure of Invention
Therefore, the invention aims to provide a data analysis method and device and electronic equipment, which can realize the rapid conversion and storage from Json format data to XML format data.
Based on the above object, the present invention provides a data parsing method, comprising:
establishing a data format corresponding table, wherein the data format corresponding table comprises a corresponding relation between a source field position of a source data format and a target field position of a target data format;
Reading a source data file in a source data format, and acquiring the source field position and the source field content corresponding to the source field position from the source data file;
searching the data format corresponding table according to the source field position, and acquiring a target field position corresponding to the source field position;
And storing the source field content in the target field position as target field content corresponding to the target field position.
Optionally, the source data format is Json format, and the target data format is XML format.
The embodiment of the invention also provides a data analysis device, which comprises:
a data format correspondence table including a correspondence between a source field location of a source data format and a target field location of a target data format;
The data reading module is used for reading a source data file in a source data format and acquiring the source field position and the source field content corresponding to the source field position from the source data file;
the searching module is used for searching the data format corresponding table according to the source field position and obtaining a target field position corresponding to the source field position;
and the data writing module is used for storing the source field content in the target field position as target field content corresponding to the target field position.
Optionally, the source data format is Json format, and the target data format is XML format.
The embodiment of the invention also provides electronic equipment, which comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor realizes the data analysis method when executing the program.
It can be seen from the foregoing that the data parsing method, apparatus and electronic device provided by the present invention include creating a data format correspondence table, reading a source data file, obtaining a source field position and a source field content corresponding to the source field position from the source data file, searching the data format correspondence table according to the source field position, obtaining a target field position corresponding to the source field position, and storing the source field content in the target field position as the target field content. The method and the device can realize the rapid conversion and storage from Json format data to XML format data, and can realize the matching and conversion of various field contents only by configuring the data format corresponding table, thereby being convenient to maintain and reducing the complexity of the program.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic flow chart of a method according to an embodiment of the invention;
fig. 2 is a schematic diagram of a device structure according to an embodiment of the present invention.
Detailed Description
The present invention will be further described in detail below with reference to specific embodiments and with reference to the accompanying drawings, in order to make the objects, technical solutions and advantages of the present invention more apparent.
It should be noted that, in the embodiments of the present invention, all the expressions "first" and "second" are used to distinguish two entities with the same name but different entities or different parameters, and it is noted that the "first" and "second" are only used for convenience of expression, and should not be construed as limiting the embodiments of the present invention, and the following embodiments are not described one by one.
FIG. 1 is a flow chart of a method according to an embodiment of the invention. As shown in the figure, the data parsing method disclosed by the embodiment of the invention comprises the following steps:
s10, establishing a data format corresponding table, wherein the data format corresponding table comprises a corresponding relation between a source field position of a source data format and a target field position of a target data format;
S11: reading a source data file in a source data format, and acquiring a source field position and corresponding source field content from the source data file;
S12: searching a data format corresponding table according to the source field position, and acquiring a target field position corresponding to the source field position;
s13: and saving the source field content corresponding to the source field position in the target field position of the target data file as target field content corresponding to the target field position.
The method of the present invention is further described below in connection with a specific example.
Data in Json format is used as a source data format, data in XML format is used as a target data format, and a data format corresponding table is established as follows:
json["color"]=xml("background","color","value");
json["document"]=xml("background","picture","document");
The data format correspondence table represents: for a Json format source data file, the source field position "color" corresponds to the target field position "background-color-value" of an XML format target data file. For example:
the data segment of the Json format source data file1 is:
the data fragment of the XML-format target data file2 is:
Reading the source data file1, acquiring a source field position 'color' and source field content '#ff 0000' corresponding to the source field position 'color' from the source data file1, searching a data format corresponding table according to the source field position 'color', acquiring a target field position 'background-color-value' corresponding to the source field position, and then storing the source field content '#ff 0000' corresponding to the source field position in the target field position of the target data file2 to serve as target field content corresponding to the target field position 'background-color-value'.
Fig. 2 is a schematic diagram of a device structure according to an embodiment of the present invention. As shown in the figure, the data parsing apparatus according to the embodiment of the present invention includes:
A data format correspondence table including a correspondence between source field locations of a source data format and target field locations of a target data format;
the data reading module is used for reading a source data file in a source data format and acquiring a source field position and corresponding source field content from the source data file;
The searching module is used for searching the data format corresponding table according to the source field position and acquiring a target field position corresponding to the source field position;
and the data writing module is used for storing the source field content corresponding to the source field position in the target field position of the target data file as target field content corresponding to the target field position.
Based on the above object, the embodiment of the present invention further provides an embodiment of an apparatus for performing the data parsing method. The device comprises:
one or more processors and memory.
The apparatus for performing the data parsing method may further include: input means and output means.
The processor, memory, input devices, and output devices may be connected by a bus or other means.
The memory is used as a non-volatile computer readable storage medium for storing non-volatile software programs, non-volatile computer executable programs and modules, such as program instructions/modules corresponding to the data analysis method in the embodiments of the present invention. The processor executes various functional applications of the server and data processing by running nonvolatile software programs, instructions and modules stored in the memory, that is, implements the data parsing method of the above method embodiment.
The memory may include a memory program area and a memory data area, wherein the memory program area may store an operating system, at least one application program required for a function; the storage data area may store data created according to the use of a device performing the data parsing method, etc. In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory optionally includes memory remotely located with respect to the processor, the remote memory being connectable to the membership user action monitoring device through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input means may receive input numeric or character information and generate key signal inputs related to user settings and function control of the device performing the data parsing method. The output means may comprise a display device such as a display screen.
The one or more modules are stored in the memory that, when executed by the one or more processors, perform the data parsing method of any of the method embodiments described above. The technical effects of the embodiment of the device for executing the data analysis method are the same as or similar to those of any of the method embodiments.
The embodiment of the invention also provides a non-transitory computer storage medium, which stores computer executable instructions that can execute the method for processing the list item operation in any of the method embodiments. Embodiments of the non-transitory computer storage medium have technical effects identical or similar to any of the method embodiments described above.
Finally, it should be noted that, as will be appreciated by those skilled in the art, all or part of the procedures in implementing the methods of the embodiments described above may be implemented by a computer program for instructing relevant hardware, where the program may be stored in a computer readable storage medium, and the program may include the procedures of the embodiments of the methods described above when executed. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a random-access Memory (Random Access Memory, RAM), or the like. The technical effects of the computer program embodiments are the same as or similar to any of the method embodiments described above.
In addition, typically, the devices, apparatuses and the like described in the present disclosure may be various electronic terminal apparatuses, such as mobile phones, personal Digital Assistants (PDAs), tablet computers (PADs), smart televisions, and the like, and may also be large-sized terminal apparatuses, such as servers, and the like, so the protection scope of the present disclosure should not be limited to a specific type of device, apparatus, and the like. The client described in the present disclosure may be applied to any of the above electronic terminal devices in the form of electronic hardware, computer software, or a combination of both.
Furthermore, the method according to the present disclosure may also be implemented as a computer program executed by a CPU, which may be stored in a computer-readable storage medium. The above-described functions defined in the methods of the present disclosure are performed when the computer program is executed by a CPU.
Furthermore, the above-described method steps and system units may also be implemented using a controller and a computer-readable storage medium storing a computer program for causing the controller to implement the above-described steps or unit functions.
Further, it should be appreciated that the computer-readable storage medium (e.g., memory) described herein can be either volatile memory or nonvolatile memory, or can include both volatile and nonvolatile memory. By way of example, and not limitation, nonvolatile memory can include Read Only Memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM), which acts as external cache memory. By way of example and not limitation, RAM may be available in a variety of forms such as synchronous RAM (DRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), and direct RambusRAM (DRRAM). The storage devices of the disclosed aspects are intended to comprise, without being limited to, these and other suitable types of memory.
The device of the foregoing embodiment is configured to implement the corresponding method in the foregoing embodiment, and has the beneficial effects of the corresponding method embodiment, which is not described herein.
Those of ordinary skill in the art will appreciate that: the discussion of any of the embodiments above is merely exemplary and is not intended to suggest that the scope of the disclosure, including the claims, is limited to these examples; the technical features of the above embodiments or in the different embodiments may also be combined within the idea of the invention, the steps may be implemented in any order and there are many other variations of the different aspects of the invention as described above, which are not provided in detail for the sake of brevity.
Additionally, well-known power/ground connections to Integrated Circuit (IC) chips and other components may or may not be shown within the provided figures, in order to simplify the illustration and discussion, and so as not to obscure the invention. Furthermore, the devices may be shown in block diagram form in order to avoid obscuring the invention, and also in view of the fact that specifics with respect to implementation of such block diagram devices are highly dependent upon the platform within which the present invention is to be implemented (i.e., such specifics should be well within purview of one skilled in the art). Where specific details (e.g., circuits) are set forth in order to describe example embodiments of the invention, it should be apparent to one skilled in the art that the invention can be practiced without, or with variation of, these specific details. Accordingly, the description is to be regarded as illustrative in nature and not as restrictive.
While the invention has been described in conjunction with specific embodiments thereof, many alternatives, modifications, and variations of those embodiments will be apparent to those skilled in the art in light of the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may use the embodiments discussed.
The embodiments of the invention are intended to embrace all such alternatives, modifications and variances which fall within the broad scope of the appended claims. Therefore, any omission, modification, equivalent replacement, improvement, etc. of the present invention should be included in the scope of the present invention.

Claims (3)

1. A data parsing method, comprising:
Establishing a data format corresponding table, wherein the data format corresponding table comprises a corresponding relation between a source field position of a source data format and a target field position of a target data format; the source data format is Json format, the target data format is XML format, and the target field position is determined according to the elements and the attributes of the data file in XML format;
Reading a source data file in a source data format, and acquiring the source field position and the source field content corresponding to the source field position from the source data file;
searching the data format corresponding table according to the source field position, and acquiring a target field position corresponding to the source field position;
And storing the source field content in the target field position as target field content corresponding to the target field position.
2. A data analysis device, comprising:
a data format correspondence table including a correspondence between a source field location of a source data format and a target field location of a target data format; the source data format is Json format, the target data format is XML format, and the target field position is determined according to the elements and the attributes of the data file in XML format;
The data reading module is used for reading a source data file in a source data format and acquiring the source field position and the source field content corresponding to the source field position from the source data file;
the searching module is used for searching the data format corresponding table according to the source field position and obtaining a target field position corresponding to the source field position;
and the data writing module is used for storing the source field content in the target field position as target field content corresponding to the target field position.
3. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of claim 1 when executing the program.
CN201811204736.5A 2018-10-16 Data analysis method and device and electronic equipment Active CN111062189B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811204736.5A CN111062189B (en) 2018-10-16 Data analysis method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811204736.5A CN111062189B (en) 2018-10-16 Data analysis method and device and electronic equipment

Publications (2)

Publication Number Publication Date
CN111062189A CN111062189A (en) 2020-04-24
CN111062189B true CN111062189B (en) 2024-07-02

Family

ID=

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105205117A (en) * 2015-09-09 2015-12-30 郑州悉知信息科技股份有限公司 Data table migrating method and device

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105205117A (en) * 2015-09-09 2015-12-30 郑州悉知信息科技股份有限公司 Data table migrating method and device

Similar Documents

Publication Publication Date Title
US20080235573A1 (en) Content Markup Transformation
AU2017302249A1 (en) Visual regression testing tool
WO2014154111A1 (en) Graphic processing method, system and server
CN111385137A (en) Terminal awakening method, server and electronic equipment
CN111352599A (en) Data processing method and device for remote whiteboard and electronic equipment
CN111062189B (en) Data analysis method and device and electronic equipment
US20140324368A1 (en) Test method, test system and electronic device employing the same
WO2015035899A1 (en) Search methods and terminals
CN111104648B (en) Software processing method and device, storage medium and electronic equipment
CN117040799A (en) Page interception rule generation and page access control method and device and electronic equipment
CN111352993A (en) Cross-platform data synchronization method and device and electronic equipment
CN112445394A (en) Screenshot method and device
CN111382415A (en) Unified login method and device and electronic equipment
CN111062189A (en) Data analysis method and device and electronic equipment
CN110992131B (en) Form processing method, form processing device and storage medium
CN110912959B (en) Equipment access method and device, management and control system and electronic equipment
CN111200621A (en) Ad hoc network method and device, and electronic device
CN111190529A (en) Keyboard input method and device and electronic equipment
CN111385491A (en) Image superposition method and device and electronic equipment
CN111324226B (en) Touch message processing method and device and electronic equipment
CN110765738A (en) System and method for generating card number and electronic equipment
US20160261674A1 (en) Providing a html file by picture transport protocol
CN111158505A (en) Thick-thin handwriting writing method and device and electronic equipment
CN110908567B (en) Terminal assistant device and method and electronic equipment
US20170075880A1 (en) Translation for web services

Legal Events

Date Code Title Description
PB01 Publication
SE01 Entry into force of request for substantive examination
GR01 Patent grant