• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Write and Update CSV files

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
while writing CSV (reading data from excel file)I'm checking (CSV file) if file exist or not in specified directory. If exist I'm trying to update existing CSV (with new rows from excel) file. If not existing I'm creating new CSV file(this part working fine).
I'm blocked while updating CSV with new rows, Please check my code and let me know the way to complete this.
 
vardhan reddy
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First I'm creating 'temp' csv file and copying existing file data into temp file and adding new rows to temp file and rename temp file name with actual name.
Trying to delete existing csv file, but not working.
using

updated code:


Can any one tell me what is issue with delete function.
 
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try closing the readers opened in below code just like you close your writer before calling the delete() method on the file object.

 
vardhan reddy
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks John, I missed that.
 
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you check our AccessingFileFormats FAQ entry you can find a few libraries that can do the hard work for you. I myself recommend opencsv.
 
vardhan reddy
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rob, I will check opencsv.
when I run my current program getting below error.

 
Rob Spoor
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's probably an embedded object in there which JExcelAPI cannot handle.
 
vardhan reddy
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I use JExcelAPI for xlsx files getting error. Changed to apache poi XSSF, now I'm able to convert xlsx files into CSV format.
When I am trying to convert large (file size around 50,000 kb) file getting Exception in thread "main" java.lang.OutOfMemoryError: Java heap space. I have increased my heap size to 1024.

-Xmx1024M

 
Bartender
Posts: 7645
178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

vardhan reddy wrote:If I use JExcelAPI for xlsx files getting error.


JExcelApi does not support XLSX, and it's unlikely that it ever will.
 
vardhan reddy
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
While testing with xlsx, came to know that.
 
That new kid is a freak. Show him this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic