How can I use Super CSV on a delimited file that does not use a quote character?


I'm using Super CSV to parse a pipe ("|") separated file. The file does not use "text qualifiers", or what Super CSV calls a quote character. The problem is that Super CSV requires a quote character. I don't see a way to skip this, or provide a null character. Currently I'm passing some wacky unicode character that hopefully never appears in the input file.

Is there a way to have Super CSV parse a file without using a quote character?

I'm guessing that you don't have control of how the file to parse is written, and that it will never contain embedded pipe characters in the data?

The solutions I can see are:

  • Use a character that will never appear in your file (as you've suggested). This is a little dodgy, but will work.

  • Supply your own Tokenizer when you construct your Reader (you can copy the Super CSV implementation and just remove the quoting functionality).

  • Send us a feature request and we'll consider adding it. It may be simply a case of adding another preference which disables quoting when parsing.

I'll have a think about this, and see if I can think of the best way to achieve this.