| Author |
creating and parsing csv files
|
m winzenburg
Greenhorn
Joined: Jul 17, 2002
Posts: 8
|
|
Has anyone written any code to create or parse CSV files? I saw a post awhile back about some freeware, but I'm not sure I can use that for commercial purposes. (Also, some of the source code was omitted, and unfortunately the classes I needed didn't compile.) From what I've read, Java's StringTokenizer and StreamTokenizer are not really designed to deal with comma-separated flat files. Yes, I can write it myself, but I thought why reinvent the wheel if there is code out there, especially for something as common as handling csv files.
|
 |
James Carman
Ranch Hand
Joined: Feb 20, 2001
Posts: 580
|
|
|
The main problem with using StringTokenizer with CSV files is that the StringTokenizer eats all the tokens that occur next to one another. So, if there are two commas in a row, it basically skips a column.
|
James Carman, President<br />Carman Consulting, Inc.
|
 |
Sayed Ibrahim Hashimi
Ranch Hand
Joined: May 17, 2001
Posts: 148
|
|
|
Why don't you use Regular Expressions I'm sure it would make your life a lot easier if you do have to implement it.
|
SCJP 1.4<br /><a href="http://www.cise.ufl.edu/~sih" target="_blank" rel="nofollow">www.cise.ufl.edu/~sih</a>
|
 |
Yoo-Jin Lee
Ranch Hand
Joined: Nov 01, 2000
Posts: 119
|
|
You can also use a jdbc driver for csv files. There are many free ones out there. -Yoo-Jin
|
 |
 |
|
|
subject: creating and parsing csv files
|
|
|