How To Do Just About Anything With CSV Files in Java

Ranked #98,496 in Computers & Electronics, #1,576,278 overall

The World's Most Evil Data File Format

Comma Separated Values. Easy. You just split on newlines and then on commas. Throw a StringTokenizer at it and you're done?

Hmm. It's not all about commas and newlines. Oh no. Excel likes you to quote any fields containing a comma or a newline. But then you can't just split the file on newlines! They might be quoted. Bummer.

And the same goes for commas. Might be quoted.

 

Not, an, easy, "file

format", to, work "with, eh?" 

 

Really means:

[Not] [an] [easy] [file format] [to] [work] [with, eh?]

 

So what's a coder to do? Well luckily there's a whole bunch of components that can hande CSV for you.

 

Java CSV Components

Note: these are not in any particular order.
StelsCSV
A CSV JDBC type 4 driver that allows you to perform SQL queries and other JDBC operations on CSV files. [Commercial]
CSV Reader
Fast and easy-to-use Java library. [Freeware]
DBMT
A Database migration tool that uses CSV. [Open Source: GPL]
CsvJdbc
A simple read-only JDBC driver that uses Comma Separated Value (CSV) files as database tables. [Open Source: LGPL]
PZFileReader
A flat file parser that handles CSV. [Open Source: Apache 2]
CSV Objects
Transparently parsing and unmarshalling CSV files and records into Plain Old Java Objects. [Open Source: GPL]
Ostermiller CSV
Utility for reading and writing CSV files. [Open Source: GPL]
Ricebridge CSV Manager
Handles high volume, very large CSV files. Data returned in multiple forms, including Arrays, Lists, Tables, ResultSets, and Java Beans (POJOs). [Commercial]
xlSQL
JDBC Driver for Excel and CSV data sources. [Open Source: GPL]
Open CSV
A very simple csv parser library. [Open Source Apache 2]

Disclaimer

As you may have noticed, I have a commercial CSV component in that list.

by

rjrodger

Richard Rodger Ricebridge Jostraca    more »

Feeling creative? Create a Lens!