简体   繁体   中英

Using CSVParser to parse a tab-delimited file

I need to parse a file which is tab delimited. I'm attempting to use CSVBeans version 0.7 to do this. In an XML configuration file, I have to pass a separator value to indicate how fields are delimited, as follows:

parser className="org.csvbeans.parsers.CSVParser"/>
    </strategy>
    <property name="separator" value="\t" />
    <property name="noStartTag" value="true" />
    <converters> 

As shown above, I have tried value="\\t" /> , but it's not working. I have also tried '\\\\t' and '\\t' but to no avail. What value should I use for a tab character?

folks it would be highly appreciated if you guys please let me know the solution specific to csv beans 0.7.1 jar .

In XML a tab character is represented as &#009; . So, your file should be like:

<parser className="org.csvbeans.parsers.CSVParser"/>
</strategy>
<property name="separator" value="&#009;" />
<property name="noStartTag" value="true" />
<converters> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM