CN110457658B - Text file configuration method and device - Google Patents
Text file configuration method and device Download PDFInfo
- Publication number
- CN110457658B CN110457658B CN201910756211.0A CN201910756211A CN110457658B CN 110457658 B CN110457658 B CN 110457658B CN 201910756211 A CN201910756211 A CN 201910756211A CN 110457658 B CN110457658 B CN 110457658B
- Authority
- CN
- China
- Prior art keywords
- format
- format adjustment
- text file
- template
- field
- 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
Links
Abstract
The invention discloses a text file configuration method and a text file configuration device, wherein the method comprises the following steps: acquiring a preset file template with a format adjustment label; and configuring the text file by using a preset file template, and adjusting the content of the text file by using a format adjustment tag according to the field format in the preset file template in the process. When the field format is regulated according to the service requirement, the content of the text file is regulated by using the format regulation label, the redevelopment and release are not needed, and the workload and the cost are small.
Description
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a text file configuration method and apparatus.
Background
In a report with text formats such as a report form and a bill, the data of the same data source need to be displayed as text files with various formats such as an ERMS (electronic report management system) format, a txt format (fields are divided by special symbols), a CSV format (fields are divided by commas), an xml format and the like. In text files with multiple formats, the data presentation format of the same field is sometimes inconsistent, for example, in an ERMS format file, a certain date field needs to be presented as 'YYYY year, MM month and DD days', but in a CSV format, the field needs to be presented as 'YYYY-MM-DD'; for example, a certain numerical field does not need to show a thousandth bit in the ERMS format file, but in the CSV format, the field needs to show a thousandth bit, and the field is a numerical type rather than a text type. In order to show the same field in files in multiple formats in different forms, it is important to provide a text file configuration method.
In the prior art, when configuring a text file, the field format of the fetched data is generally adjusted when fetching from a database, and the text file with a required format is directly configured and generated. If the field format is adjusted by the service requirement, the requirement can be met by re-developing and releasing, and the workload and the cost are large.
Disclosure of Invention
The embodiment of the invention provides a text file configuration method for reducing workload and cost, which comprises the following steps:
acquiring a preset file template with a format adjustment label;
configuring a text file by using a preset file template, and adjusting the content of the text file by using the format adjustment tag according to the field format in the preset file template in the process;
the parameter information of the format adjustment label comprises: numerical information and field information;
adjusting the content of the text file by using the format adjustment tag comprises the following steps:
acquiring parameter information of each format adjustment label, and judging whether the parameter information of the format adjustment label is numerical value information or not;
if yes, acquiring format adjustment parameters of the numerical value information, and adjusting the content in the text file according to the format adjustment parameters;
otherwise, the field information is adjusted.
Optionally, obtaining the preset file template with the format adjustment tag includes:
and generating a preset file template by using a template engine according to the user demand, and adding a format adjustment label for adjusting the field format into the preset file template in the process.
Optionally, the parameter information of the format adjustment tag includes: numerical information and field information.
Optionally, adjusting the content of the text file by using the format adjustment tag includes:
acquiring parameter information of each format adjustment label, and judging whether the parameter information of the format adjustment label is numerical value information or not;
if yes, acquiring format adjustment parameters of the numerical value information, and adjusting the content in the text file according to the format adjustment parameters;
otherwise, the field information is adjusted.
The embodiment of the invention also provides a text file configuration device for reducing the workload and the cost, which comprises:
the data acquisition module is used for acquiring a preset file template with a format adjustment label;
the text configuration module is used for configuring a text file by using a preset file template, and in the process, the content of the text file is adjusted by using the format adjustment tag according to the field format in the preset file template;
the parameter information of the format adjustment label comprises: numerical information and field information;
the text configuration module is further to:
acquiring parameter information of each format adjustment label, and judging whether the parameter information of the format adjustment label is numerical value information or not;
if yes, acquiring format adjustment parameters of the numerical value information, and adjusting the content in the text file according to the format adjustment parameters;
otherwise, the field information is adjusted.
Optionally, the data acquisition module is further configured to:
and generating a preset file template by using a template engine according to the user demand, and adding a format adjustment label for adjusting the field format into the preset file template in the process.
Optionally, the parameter information of the format adjustment tag includes: numerical information and field information.
Optionally, the text configuration module is further configured to:
acquiring parameter information of each format adjustment label, and judging whether the parameter information of the format adjustment label is numerical value information or not;
if yes, acquiring format adjustment parameters of the numerical value information, and adjusting the content in the text file according to the format adjustment parameters;
otherwise, the field information is adjusted.
The embodiment of the invention also provides computer 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 method when executing the computer program.
Embodiments of the present invention also provide a computer-readable storage medium storing a computer program for executing the above method.
In the embodiment of the invention, the text file is configured by acquiring the preset file template with the format adjustment tag and utilizing the preset file template, and in the process, the content of the text file is adjusted by utilizing the format adjustment tag according to the field format in the preset file template. When the field format is regulated by the service requirement, the content of the text file is regulated by the format regulation label, the redevelopment and release are not needed, and the workload and the cost are small.
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. In the drawings:
FIG. 1 is a flow chart of a text file configuration method according to an embodiment of the invention;
FIG. 2 is a schematic diagram of a text file configuration device according to an embodiment of the present invention;
fig. 3 is a schematic flow chart of adjusting a text file by using a format adjustment tag according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the embodiments of the present invention will be described in further detail with reference to the accompanying drawings. The exemplary embodiments of the present invention and their descriptions herein are for the purpose of explaining the present invention, but are not to be construed as limiting the invention.
In a report with text formats such as a report form and a bill, the data of the same data source need to be displayed as text files with various formats such as an ERMS (electronic report management system) format, a txt format (fields are divided by special symbols), a CSV format (fields are divided by commas), an xml format and the like. In text files with multiple formats, the data presentation format of the same field is sometimes inconsistent, for example, in an ERMS format file, a certain date field needs to be presented as 'YYYY year, MM month and DD days', but in a CSV format, the field needs to be presented as 'YYYY-MM-DD'; for example, a certain numerical field does not need to show a thousandth bit in the ERMS format file, but in the CSV format, the field needs to show a thousandth bit, and the field is a numerical type rather than a text type. In order to show the same field in files in multiple formats in different forms, it is important to provide a text file configuration method.
In the prior art, when configuring a text file, the field format of the fetched data is generally adjusted when fetching from a database, and the text file with a required format is directly configured and generated. If the field format is adjusted by the service requirement, the requirement can be met by re-developing and releasing, and the workload and the cost are large.
In order to solve the above problems, an embodiment of the present invention provides a text file configuration method, as shown in fig. 1, including:
step 101, obtaining a preset file template with a format adjustment label.
In the implementation, a preset file template can be generated by using a template engine according to the requirement of a user, and in the process, a format adjustment label for adjusting the format of a field is added into the preset file template.
Wherein the template engine may use FreeMarker.
And 102, configuring a text file by using the preset file template, and adjusting the content of the text file by using the format adjustment tag according to the field format in the preset file template in the process.
In the embodiment of the invention, the parameter information of the format adjustment label comprises: numerical information and field information.
As shown in fig. 3, the content of the text file is adjusted by using the format adjustment tag, which includes:
acquiring parameter information of each format adjustment label, and judging whether the parameter information of the format adjustment label is numerical value information or not;
if yes, acquiring format adjustment parameters of the numerical value information, and adjusting the content in the text file according to the format adjustment parameters;
otherwise, the field information is adjusted.
According to the text file configuration method provided by the embodiment of the invention, the preset file template with the format adjustment label is obtained, the text file is configured by utilizing the preset file template, and in the process, the content of the text file is adjusted by utilizing the format adjustment label according to the field format in the preset file template. When the field format is regulated by the service requirement, the content of the text file is regulated by the format regulation label, the redevelopment and release are not needed, and the workload and the cost are small.
The invention is illustrated in the following by way of a specific example:
the name of the field interception tag is set as fmt, and the parameters are as follows:
id: setting a field name in a record set corresponding to each field;
type: s character string type, N value type;
format: format adjustment format, date format such as: YYYY-MM-DD, YYYY/MM/DD, etc.; the numerical format is as follows: #0.000, #0.0, etc.;
examples in the file template are as follows:
<@fmt id="detail.BGNDT"type="N"format="YYYY-MM-DD"/>
the tag means that the BGNDT field content in the detail record set is displayed in YYYY-MM-DD format, and the format is adjusted as 2018-10-11.
<@fmt id="detail.TRAN_AMOUNT"type="N"format="#,##0.000"/>
The meaning of the tag is that the TRAN_AMOUNT field in the detail record set is formatted according to decimal 3 bits using a thousandth bit partitioner, such as 145,679,155,345.452.
As another example, for instance, there are 2 formats (assumed to be erm system format and CSV format) for the same document, the contents of the documents are the same, but the document field formats are different, the date of the document of the kind needs to be displayed as yyyymmd, and the other document is displayed as YYYY-MM-DD. According to the prior art method, the field format adjustment can only be put into the data fetch logic, i.e. the field is adjusted in the data fetch logic, so that the two documents need to write 2 data fetch logics, one needs to adjust the date to the yyyyymd format, and the other needs to adjust the date to the YYYY-MM-DD format. If there are a variety of different needs, then a variety of logic needs to be developed. After the field format adjustment label is adopted, only one data access logic is needed (the field format adjustment problem is not needed to be considered), and whether the specific field format is adjusted or not is finished by the field format adjustment label in the report template.
In addition, when a new requirement exists for a business, for example, the date format is adjusted from yyyymmd to yyyyy-MM-DD, according to the conventional method, the data access logic (in which the date format is adjusted to yyyymmd) needs to be adjusted, and the data access logic is implemented in a program, for example, a java program, so that the code needs to be compiled into an execution code, and after a series of processes of development, test, version out and the like are performed, and after the format adjustment label is adopted, the adjustment of label parameters is only required to be performed on production, so that the requirement of a customer can be responded quickly.
Based on the same inventive concept, the embodiment of the invention also provides a text file configuration device, as described in the following embodiment. Since the principle of the text file configuration device for solving the problem is similar to that of the text file configuration method, the implementation of the text file configuration device can refer to the implementation of the text file configuration method, and the repetition is omitted. As used below, the term "unit" or "module" may be a combination of software and/or hardware that implements the intended function. While the means described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and contemplated.
An embodiment of the present invention provides a text file configuration device, as shown in fig. 2, where the device includes:
the data acquisition module 201 is configured to acquire a preset file template with a format adjustment tag.
The text configuration module 202 is configured to configure the text file by using the preset file template, and in this process, the content of the text file is adjusted by using the format adjustment tag according to the field format in the preset file template.
In an embodiment of the present invention, the data acquisition module 201 is further configured to:
and generating a preset file template by using a template engine according to the user demand, and adding a format adjustment label for adjusting the field format into the preset file template in the process.
In the embodiment of the present invention, the parameter information of the format adjustment tag includes: numerical information and field information.
In an embodiment of the present invention, the text configuration module 202 is further configured to:
acquiring parameter information of each format adjustment label, and judging whether the parameter information of the format adjustment label is numerical value information or not;
if yes, acquiring format adjustment parameters of the numerical value information, and adjusting the content in the text file according to the format adjustment parameters;
otherwise, the field information is adjusted.
The embodiment of the invention also provides computer 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 method when executing the computer program.
Embodiments of the present invention also provide a computer-readable storage medium storing a computer program for executing the above method.
It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The foregoing description of the embodiments has been provided for the purpose of illustrating the general principles of the invention, and is not meant to limit the scope of the invention, but to limit the invention to the particular embodiments, and any modifications, equivalents, improvements, etc. that fall within the spirit and principles of the invention are intended to be included within the scope of the invention.
Claims (6)
1. A text file configuration method, comprising:
acquiring a preset file template with a format adjustment label;
configuring a text file by using a preset file template, and adjusting the content of the text file by using the format adjustment tag according to the field format in the preset file template in the process;
the parameter information of the format adjustment label comprises: numerical information and field information;
adjusting the content of the text file by using the format adjustment tag comprises the following steps:
acquiring parameter information of each format adjustment label, and judging whether the parameter information of the format adjustment label is numerical value information or not;
if yes, acquiring format adjustment parameters of the numerical value information, and adjusting the content in the text file according to the format adjustment parameters;
otherwise, the field information is adjusted.
2. The method of claim 1, wherein obtaining a pre-set document template with a formatting tag comprises:
and generating a preset file template by using a template engine according to the user demand, and adding a format adjustment label for adjusting the field format into the preset file template in the process.
3. A text file configuration apparatus, comprising:
the data acquisition module is used for acquiring a preset file template with a format adjustment label;
the text configuration module is used for configuring a text file by using a preset file template, and in the process, the content of the text file is adjusted by using the format adjustment tag according to the field format in the preset file template;
the parameter information of the format adjustment label comprises: numerical information and field information;
the text configuration module is further to:
acquiring parameter information of each format adjustment label, and judging whether the parameter information of the format adjustment label is numerical value information or not;
if yes, acquiring format adjustment parameters of the numerical value information, and adjusting the content in the text file according to the format adjustment parameters;
otherwise, the field information is adjusted.
4. The apparatus of claim 3, wherein the data acquisition module is further to:
and generating a preset file template by using a template engine according to the user demand, and adding a format adjustment label for adjusting the field format into the preset file template in the process.
5. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method of any of claims 1 to 2 when executing the computer program.
6. A computer readable storage medium, characterized in that the computer readable storage medium stores a computer program for executing the method of any one of claims 1 to 2.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910756211.0A CN110457658B (en) | 2019-08-16 | 2019-08-16 | Text file configuration method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910756211.0A CN110457658B (en) | 2019-08-16 | 2019-08-16 | Text file configuration method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110457658A CN110457658A (en) | 2019-11-15 |
CN110457658B true CN110457658B (en) | 2023-10-27 |
Family
ID=68487028
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910756211.0A Active CN110457658B (en) | 2019-08-16 | 2019-08-16 | Text file configuration method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110457658B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111125997A (en) * | 2019-12-27 | 2020-05-08 | 中国银行股份有限公司 | Text data standardization processing method and device |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107506182A (en) * | 2017-07-27 | 2017-12-22 | 努比亚技术有限公司 | Software layout method, software merit rating device and computer-readable recording medium |
CN108763171A (en) * | 2018-04-20 | 2018-11-06 | 中国船舶重工集团公司第七〇九研究所 | A kind of document automation generation method based on format module |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20060259456A1 (en) * | 2005-05-10 | 2006-11-16 | Alexander Falk | System for describing text file formats in a flexible, reusable way to facilitate text file transformations |
US8762834B2 (en) * | 2006-09-29 | 2014-06-24 | Altova, Gmbh | User interface for defining a text file transformation |
-
2019
- 2019-08-16 CN CN201910756211.0A patent/CN110457658B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107506182A (en) * | 2017-07-27 | 2017-12-22 | 努比亚技术有限公司 | Software layout method, software merit rating device and computer-readable recording medium |
CN108763171A (en) * | 2018-04-20 | 2018-11-06 | 中国船舶重工集团公司第七〇九研究所 | A kind of document automation generation method based on format module |
Also Published As
Publication number | Publication date |
---|---|
CN110457658A (en) | 2019-11-15 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10496741B2 (en) | Dynamic intermediate templates for richly formatted output | |
CN100578495C (en) | Method and system for exposing nested data in a computer-generated document in a transparent manner | |
WO2020033059A1 (en) | Data re-use across documents | |
US20100057760A1 (en) | Generic data retrieval | |
CN102810057A (en) | Log recording method | |
CN106933887B (en) | Data visualization method and device | |
CN108021632B (en) | Mutual conversion processing method for unstructured data and structured data | |
WO2017114188A1 (en) | Printing apparatus and printing method | |
US10659567B2 (en) | Dynamic discovery and management of page fragments | |
CN111159982A (en) | Document editing method and device, electronic equipment and computer readable storage medium | |
CN110457658B (en) | Text file configuration method and device | |
CN113449236A (en) | Method and device for generating and storing electronic protocol of bank system | |
US20130097487A1 (en) | Single view representation of an xls transformation | |
CN108319869B (en) | Automatic bid opening method, device, server and storage medium | |
US20160103815A1 (en) | Generating mobile web browser views for applications | |
US11605012B2 (en) | Framework for processing machine learning model metrics | |
CN116301856B (en) | Design method, device, equipment and medium of visual form designer | |
US20150169515A1 (en) | Data driven synthesizer | |
CN102067118B (en) | Method and device for storing data belonging to an alarm or event message containing multiple attributes | |
US10185706B2 (en) | Generating web browser views for applications | |
CN112115694B (en) | Simulation report generation method and device based on multi-element data structure | |
US20120268482A1 (en) | User interface rendering and operating method, a computer program product, and a ui rendering and operating system | |
US8959246B2 (en) | Method and computer program for a mediation processing node to update a message | |
CN112000366B (en) | System parameter configuration method and device based on code generator | |
CN112000414B (en) | Configurable display method and device for parameter information |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |