Do I need a library if I only need to make csv formatted file. I don't need reading and parsing it.
Asked
Active
Viewed 554 times
2 Answers
2
No, you don't. And even reading/parsing can be easily done with a plain JRE.
CSV is a plain (ascii-)text format with only a few rules:
- rows (objects) are separated with a
\n
- columns (fields, attributes) are spearated with a delimiter char (usually a comma, but define whatever you need)
- row and column delimiters must not be part of the field values

Andreas Dolk
- 113,398
- 19
- 180
- 268
-
-
That is so bad. Of course you are right. But why does everyone have to implement this manually? Why isn't there just a simple class in the Java collections or io API that does this?? I'm sick of having to think of escaping `";", ",", "\t", "\""` and all that again and again... :-( – Lukas Eder Jun 24 '11 at 09:39
-
@Lukas Eder - why don't you just implement your own private toolbox that has, amongst other stuff, some static helper methods for csv files ;-) – Andreas Dolk Jun 25 '11 at 21:39
-
-
Don't forget platform-specific line terminators (*N.B.* fields can contain line terminators), and quoting. – user359996 Nov 30 '12 at 20:13
1
Unless it's a really trivial part of your application and you're absolutely sure you won't ever need to parse a CSV file, you need a CSV-serialization library.
I have tried openCSV and I'm pretty happy using it. Of course you can write your own class to handle this serialization, but a library always comes with more features at the expense of an extra dependency...

Pantelis Sopasakis
- 1,902
- 5
- 26
- 45