tags:

views:

1271

answers:

5

I've found numerous posts about reading CSV with Java and the APIs they were pointing at all had a line-oriented approach when it came to reading a CSV file. Something like "while you get a line, get the values of every column".

I'd appreciate a higher-level API, like in Perl where DBI allows you to use SQL on CSV like if it where a DB table. Otherwise I'll have to implement lots of access logic by myself.

Is there such an API? Am I missing something? There are some references about JDBC drivers but most are projects that haven't been updated the last 5 years.

A: 

yes, JDBC with a CSV driver. You can try implement yourself or just try something like HXTT

dfa
A: 

You could give H2Database a go - it is rather heavy weight, but at least it is maintained.

Reuben Peeris
A: 

This link might get you started in the right direction.

HTH

Anand
+2  A: 

You can use HSQL in order to do it, see the following links from the docs and a blog post describing exactly that.

David Rabinowitz
A: 

Are you trying to avoid using a regular database for accessing CSV? MySQL supports CSV as one of it's table types if you are open to using a database system.

Brent Baisley