• 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

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: 22781
131
Eclipse IDE Spring VI Editor 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: 22781
131
Eclipse IDE Spring VI Editor 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

 
Saloon Keeper
Posts: 7582
176
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic