• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Reading a CSV file as same in Excel

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic