A kind of method of xml document batch programming count data

文档序号:1771908 发布日期:2019-12-03 浏览:35次 中文

阅读说明:本技术 一种xml文件批量自动统计数据的方法 (A kind of method of xml document batch programming count data ) 是由 程永新 林小勇 段文香 于 2019-09-03 设计创作,主要内容包括:本发明公开了一种xml文件批量自动统计数据的方法,包括以下步骤:步骤S101:规范xml文件的命名和目录的放置;步骤S102:将所述xml文件批量导入数据库,根据所述XML的文件名称分类,创建对应的数据表;步骤S103:执行python导入程序,批量自动把所述xml文件导入数据库对应的表。本发明提供的xml文件批量自动统计数据的方法,每个步骤都按不同时间通过程序脚本自动化操作,减少了人为操作和统计时间,大大提高工作效率。(The invention discloses a kind of methods of xml document batch programming count data, the following steps are included: step S101: the name of specification xml document and the placement of catalogue;Step S102: the xml document batch is imported into database, is classified according to the file name of the XML, creates corresponding tables of data;Step S103: it executes python and imports program, the xml document is imported the corresponding table of database automatically by batch.The method of xml document batch programming count data provided by the invention, each step press different time by procedure script automatic operation, reduce manual operation and statistical time, greatly improve working efficiency.)

1. a kind of method of xml document batch programming count data, which comprises the following steps:

Step S101: the name of specification xml document and the placement of catalogue;

Step S102: the xml document batch is imported into database, is classified according to the file name of the XML, is created corresponding Tables of data;

Step S103: it executes python and imports program, the xml document is imported the corresponding table of database automatically by batch.

2. the method for xml document batch programming count data as described in claim 1, which is characterized in that in the step Further include step S104 after S103: counting the xml document for importing database as required, exports electricity after generating statistical result Sub-table carries out filing preservation.

3. the method for xml document batch programming count data as described in claim 1, which is characterized in that in the step It further include the trusting relationship established between the server for being responsible for statistics and xml generation file server before S101, it will be described negative The server and the xml for blaming statistics generate the account number of file server and password writes the variable in script.

4. the method for xml document batch programming count data as described in claim 1, which is characterized in that in step s 103, If batch malfunctions when the xml document being imported the corresponding table of database automatically, the importing program, rollback can be interrupted in time The data of tables of data prevent database data redundancy, and log are written in error reason.

5. the method for xml document batch programming count data as claimed in claim 2, which is characterized in that described to unite as required Counting the xml document for importing database includes that sql sentence is write out by statistical requirements, calls the sql language by shell script Sentence exports electrical form after generating statistical result, carries out filing preservation.

6. the method for xml document batch programming count data as claimed in claim 5, which is characterized in that after the completion of statistics, By the shell script, the derived electrical form is classified under statistics catalogue.

7. the method for xml document batch programming count data as claimed in claim 5, which is characterized in that pass through the shell The electrical form is carried out filing preservation by the date of statistics by script.

Technical field

The present invention relates to a kind of method of statistical data more particularly to a kind of sides of xml document batch programming count data Method.

Background technique

Xml is a kind of flag data, defines data type, the source language for allowing user to be defined the markup language of oneself Speech is suitble to the transmission of internet.It is handled in big data transmission with preservation, the xml document number of transmission is all thousands of, data Amount can reach GB rank in single file.Administrator often can be read out xml document to be counted with inspection, then writes out report knot Fruit obtains service operation problem.Following two method would generally be used:

(1) manual type reads and analyzes, and single xml document changed into electrical form, then the letter for passing through electrical form Row is analyzed when number comes.

(2) it is solved by traditional program, first XML data is led in memory, then counts again, export statistical result, It is further continued for reading next xml analysis, until having handled all xml documents.

Existing large-scale xml data file conventional process mode can have the disadvantage in that

(1) inefficiency: be first it is artificial encountered more than data volume by conversion xml format, it is converted at of long duration and It can malfunction.If encountering hundreds and thousands of a xml documents, that will consume a large amount of time to count, waste of manpower cost.

(2) by traditional program come processing mode, suitable for a small amount of xml document, as data increase, processing needs to spend Take a large amount of time.

(3) it needs manual operation: being transferred to arrangement to execution program to importing electrical form is terminated, all from xml document Manual operation is needed, it is high to operator's technical requirements.

(4) it consumes computer performance: needing to be stored in memory since program reads xml, and reading process needs to consume A large amount of IO, when the performance of data volume more than one, computer will arrive bottleneck.

(5) reading for a long time unsuccessfully causes to retract: if reading unsuccessfully leads to program interrupt, meeting when reading xml document The data failure of memory is saved in front of causing, restarting reading will also take a significant amount of time.

(6) dilatancy is insufficient: the scale if necessary to statistics becomes larger, and increases multiple xml documents newly, it is necessary to change source generation Code, dilatation scheme also can be more difficult.

Therefore, it is necessary to provide a kind of method of xml document batch programming count data, a large amount of xml documents can be promoted Handle the efficiency of data.

Summary of the invention

Technical problem to be solved by the invention is to provide a kind of methods of xml document batch programming count data, each Step all presses different time by procedure script automatic operation, reduces manual operation and statistical time, greatly improves work Efficiency.

The present invention is to solve above-mentioned technical problem and the technical solution adopted is that provide a kind of xml document batch programming count The method of data, comprising the following steps:

Step S101: the name of specification xml document and the placement of catalogue;

Step S102: importing database for the xml document batch, classified according to the file name of the XML, creation pair The tables of data answered;

Step S103: it executes python and imports program, the xml document is imported the corresponding table of database automatically by batch.

Preferably, further include step S104 after the step S103: counting the xml for importing database as required File exports electrical form after generating statistical result, carries out filing preservation.

It preferably, further include establishing the server for being responsible for statistics and xml generation file service before the step S101 The server of the responsible statistics and the xml are generated the account number of file server and password are write by the trusting relationship between device Variable into script.

Preferably, in step s 103, if batch goes out when the xml document being imported the corresponding table of database automatically Mistake, can interrupt the importing program in time, and the data of rollback tables of data prevent database data redundancy, and error reason is write Enter log.

Preferably, the xml document for counting the importing database as required includes that sql language is write out by statistical requirements Sentence calls the sql sentence by shell script, exports electrical form after generating statistical result, carry out filing preservation.

Preferably, after the completion of statistics, by the shell script, the derived electrical form is classified It counts under catalogue.

Preferably, by the shell script, the electrical form is subjected to filing preservation by the date of statistics.

The present invention comparison prior art has following the utility model has the advantages that xml document batch programming count number provided by the invention According to method, each step presses different time by procedure script automatic operation, reduces manual operation and statistical time, Greatly improve working efficiency.

Detailed description of the invention

Fig. 1 is the flow chart of the method for xml document batch programming count data in the embodiment of the present invention;

Fig. 2 is the flow chart of the method for xml document batch programming count data in another embodiment of the present invention.

Specific embodiment

The invention will be further described with reference to the accompanying drawings and examples.

In the following description, in order to provide thorough understanding of the invention, many concrete details are elaborated.However, this hair Bright to practice in the case where these no concrete details, this will be aobvious and easy for the common technical staff in this field See.Therefore, concrete details elaboration is only exemplary, and concrete details can be changed by bold and unrestrained spirit and scope And it is still considered as within the spirit and scope of the present invention.

A kind of method of xml document batch programming count data provided in this embodiment, each step press different time By procedure script automatic operation, reduce manual operation and statistical time, greatly improves working efficiency.

Referring now to Fig. 1, present embodiment discloses a kind of method of xml document batch programming count data, including it is following Step: step S101: the name of specification xml document and the placement of catalogue;Step S102: the xml document batch is imported into number According to library, is classified according to the file name of the XML, create corresponding tables of data;Step S103: executing python and import program, The xml document is imported the corresponding table of database automatically by batch.

It preferably, further include establishing the server for being responsible for statistics and xml generation file service before the step S101 The server of the responsible statistics and the xml are generated the account number of file server and password are write by the trusting relationship between device Variable into script.

Preferably, in step s 103, if batch goes out when the xml document being imported the corresponding table of database automatically Mistake, can interrupt the importing program in time, and the data of rollback tables of data prevent database data redundancy, and error reason is write Enter log.

Preferably, the xml document for counting the importing database as required includes that sql language is write out by statistical requirements Sentence calls the sql sentence by shell script, exports electrical form after generating statistical result, carry out filing preservation.

Preferably, after the completion of statistics, by the shell script, the derived electrical form is classified It counts under catalogue.

Preferably, by the shell script, the electrical form is subjected to filing preservation by the date of statistics.

Referring now to Fig. 2, present embodiment discloses a kind of method of xml document batch programming count data, including it is following Step: step S101: the name of specification xml document and the placement of catalogue;Step S102: the xml document batch is imported into number According to library, is classified according to the file name of the XML, create corresponding tables of data;Step S103: executing python and import program, The xml document is imported the corresponding table of database automatically by batch;Step S104: the importing database is counted as required Xml document exports electrical form after generating statistical result, carries out filing preservation.

It preferably, further include establishing the server for being responsible for statistics and xml generation file service before the step S101 The server of the responsible statistics and the xml are generated the account number of file server and password are write by the trusting relationship between device Variable into script.

Preferably, in step s 103, if batch goes out when the xml document being imported the corresponding table of database automatically Mistake, can interrupt the importing program in time, and the data of rollback tables of data prevent database data redundancy, and error reason is write Enter log.

Preferably, the xml document for counting the importing database as required includes that sql language is write out by statistical requirements Sentence calls the sql sentence by shell script, exports electrical form after generating statistical result, carry out filing preservation.

Preferably, after the completion of statistics, by the shell script, the derived electrical form is classified It counts under catalogue.

Preferably, by the shell script, the electrical form is subjected to filing preservation by the date of statistics.

The present invention comparison prior art has following the utility model has the advantages that xml document batch programming count number provided by the invention According to method, each step presses different time by procedure script automatic operation, reduces manual operation and statistical time, Greatly improve working efficiency.

Further, the method for xml document batch programming count data provided by the invention reduces logic complexity, step It only needs to obtain implementing result between rapid, woth no need to be concerned about how to realize.If there is newly-increased XML file, need to only write After code, each step is added by planning, it is not necessary to modify source codes, more quick and standardized management code.

It is possible to further replace manually, reducing the fault in manual operation, reducing the loss of enterprise with machine code.

Further, employee only needs the work that can take up an official post by simple professional training, without learning excessive technology. It avoids excessively dependent on familiarity of the treatment people for system, the conditions such as technical level save enterprise's cost of labor.

Although the present invention is disclosed as above with preferred embodiment, however, it is not to limit the invention, any this field skill Art personnel, without departing from the spirit and scope of the present invention, when can make a little modification and perfect therefore of the invention protection model It encloses to work as and subject to the definition of the claims.

6页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:可动态扩展特权账号扫描系统集成外部系统的方法及装置

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!