• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading a CSV file as same in Excel

 
Ganni Kal
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Assume that the a comma separated text file (namely user.txt) contains data as below:

""AB"",CD","1407"


I converted the text file into a csv file (just by changing the file extension to .csv named as user.csv). and while opening the csv file through MS Excel application the data
is displayed in three columns as below:

col1 col2 col3
----- ------ -------
AB"" CD" 1407


Is there any java API / or program, to parse the text file (user.txt) and extract the data as same as excel?


Thanks
Ganni
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CSV has rules that go beyond separating items by commas (or semicolons). For example, double quotes that should appear literally need to be escaped, and items that include commas need to be enclosed by double quotes. Before you've coded all those, it may be easier to use a ready-made library for reading and writing CSV files. The http://faq.javaranch.com/java/AccessingFileFormats page lists several such libraries.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!