[OFBiz] Users - exception in reading delimited flat file

deepak sahu post2deepak at yahoo.co.in
Fri May 20 03:39:44 EDT 2005


Hi All
I was successfully able to read/write fixed-lenght
flat-files and write to a flat-file.
But I tried to read the same delimited flat-file which
I had written earlier using the Datafile apis and got
an exception.

My Datafile model for delimited flat-file is as
follows:

<?xml version="1.0" encoding="UTF-8"?>
<data-files
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:noNamespaceSchemaLocation="C:\Documents and
Settings\deepakks\Desktop\datafiles.xsd">
<data-file type-code="text"
separator-style="delimited" name="TestFile"
delimiter=";">
<record name="TestRecord">
  <field  name="CustNo" type="String" position="1"/>
  <field  name="FirstName" type="String"
position="2"/>	</record>
</data-file>
</data-files>

My bsh file snippet which is used to read the
delimited-file is:

DataFile
df=DataFile.readFile(UtilURL.fromFilename("D:\\ofbizFiles\\outPutFile2"),
  
UtilURL.fromResource("XMLModelVar.xml"),"TestFile");
String message=df.writeDataFile();

The outPutFile2 has only one record:

1;Deepak;

The Exception is:

org.ofbiz.datafile.DataFileException: Field CustNo
from 1 for -1 chars could not
be read from a line (1) with only 9 chars. (String
index out of range: -1)

Q1.Am I missing something in the Datafile model?
Q2.Could somebody plz tell me about the use of 
	1. typeCode
	2. tcPosition
	3. tcMax/tcMin
	4. tcLength
Q3.Is the "length" attribute of the <field> required
in   the model in case of delimited files?
The datafiles.xsd says it is mandatory.

I would really appreciate some help.
Thanks a lot.
Deepak



________________________________________________________________________
Yahoo! India Matrimony: Find your life partner online
Go to: http://yahoo.shaadi.com/india-matrimony


More information about the Users mailing list