aspose file tools*
The moose likes Java in General and the fly likes Write and Update CSV files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Write and Update CSV files" Watch "Write and Update CSV files" New topic
Author

Write and Update CSV files

vardhan reddy
Ranch Hand

Joined: Oct 28, 2011
Posts: 42
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

Joined: Oct 28, 2011
Posts: 42
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.
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
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

Joined: Oct 28, 2011
Posts: 42
Thanks John, I missed that.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19784
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
vardhan reddy
Ranch Hand

Joined: Oct 28, 2011
Posts: 42
Rob, I will check opencsv.
when I run my current program getting below error.

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19784
    
  20

There's probably an embedded object in there which JExcelAPI cannot handle.
vardhan reddy
Ranch Hand

Joined: Oct 28, 2011
Posts: 42
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
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
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

Joined: Oct 28, 2011
Posts: 42
While testing with xlsx, came to know that.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Write and Update CSV files