eseifert / gral

Free Java library for displaying plots
GNU General Public License v3.0
166 stars 32 forks source link

Better support for CSV/TSV files #51

Closed eseifert closed 9 years ago

eseifert commented 9 years ago

At the moment GRAL only supports very a simple form of CSV. Although the CSV format is considered to be an easy exchange format, countless variants exist. There are quoted values, different characters for quoting, escaping, newline, etc.

The CSVReader and CSVWriter plug-ins should have more settings and be more configurable to the different variants.

Imported from trac ticket #52, created by eseifert on 11-28-2011 at 02:44, last modified: 11-28-2011 at 03:01

eseifert commented 9 years ago

Major changes were done in r405 that will make CSVReader more flexible. [https://tools.ietf.org/html/rfc4180 RFC 4180] was used as a reference for the new implementation. And the reader employs the StatefulTokenizer class to apply more complex rules for parsing. This way, quoting and escaping are now possible.

At the moment double quotes are hard coded and quoting a value like

"foo;bar";foo;bar

will now output three string foo;bar, foo, and bar.

Escaping the quotes by doubling:

"foo""the""bar"

will now output the string foo"the"bar containing the quotes.

Additionally, settings have been changed from strings to static constants, like SEPARATOR_CHAR. Once the new class has been thoroughly tested, more settings will be added

Trac comment by eseifert on 11-28-2011 at 03:01