/[Apache-SVN]
ViewVC logotype

Revision 1819147


Jump to revision: Previous Next
Author: nmalin
Date: Sat Dec 23 13:42:15 2017 UTC (6 years, 3 months ago)
Changed paths: 4
Log Message:
Improved: Import file with data-file, add start-line to escape the header column line (OFBIZ-10108)

When you load a CSV file some time with a data-file definition, if it contains some header column you can use the format attribute of you column.
Example:
ref;date
100;2017-10-10
200;2017-12-11

This definition failed :
    <data-file name="MyCsvTest" separator-style="delimited" type-code="text" delimiter=";">
        <record name="Test">
            <field name="ref" type="String" position="1"/>
            <field name="date" type="CustomTimestamp" format="yyyyy-MM-dd" position="2"/>
        </record>
     </data-file>

You need to read the date as string and after convert it on your code to escape the first line.
To solve it I added a new attribute start-line on data-file element :
    <data-file name="MyCsvTest" separator-style="delimited" type-code="text" *start-line="1"* delimiter=";">
        <record name="Test">
            <field name="ref" type="String" position="1"/>
            <field name="date" type="CustomTimestamp" format="yyyyy-MM-dd" position="2"/>
        </record>
     </data-file>

Changed paths

Path Details
Directoryofbiz/ofbiz-framework/trunk/framework/datafile/dtd/datafiles.xsd modified , text changed
Directoryofbiz/ofbiz-framework/trunk/framework/datafile/src/main/java/org/apache/ofbiz/datafile/ModelDataFile.java modified , text changed
Directoryofbiz/ofbiz-framework/trunk/framework/datafile/src/main/java/org/apache/ofbiz/datafile/ModelDataFileReader.java modified , text changed
Directoryofbiz/ofbiz-framework/trunk/framework/datafile/src/main/java/org/apache/ofbiz/datafile/RecordIterator.java modified , text changed

infrastructure at apache.org
ViewVC Help
Powered by ViewVC 1.1.26