0

I want parse file with delimeter. I use BeanIO 2.1.0. I have file, which contains a string in which there is a double quote:

"TEST"/37326330|TEST2

In config I set parameter:

<stream name="csvStream" format="csv">
     <parser>
         <property name="delimiter" value="|"/>
         <property name="unquotedQuotesAllowed" value="true"/>
     </parser>
</stream>

But it not working! I get error:

org.beanio.MalformedRecordException: Malformed record at line 1: Invalid character found outside of quoted field at line 1

But why? Why this parameter not working?

All_Safe
  • 1,339
  • 2
  • 23
  • 43

1 Answers1

1

I'm going to assume that you want to preserve/retain the double quotes (").

The unquotedQuotesAllowed config option is only applicable to CSV streams, but based on your sample test data, you are using a pipe symbol (|) as a delimiter. Yes, you can change the delimiter for a CSV stream, but I think it would be better to just use a stream mapping configured as a delimited format. IMO this is easier to work with and you don't need to comply to all the rules and subtleties of a CSV format.

I would then use the following:

<stream name="csvStream" format="delimited">
  <parser>
    <property name="delimiter" value="|"/>
  </parser>
  <record name="...">
  ....
  </record>
</stream>

Using the above mapping, I get the following output:

Field1: "TEST"/37326330, Field2: TEST2
nicoschl
  • 2,346
  • 1
  • 17
  • 17