Akhilesh Murthy wrote:Hi The file formats had more of parsers and reader API's. My requirement was mainly for writing into specific fields of the file.
You can't write directly into a single field of a CSV file. You have to read the file into memory, change what you want to change, and write it back out. Note that you can operate on one line at a time--you don't necessarily have to have the entire file in memory.
As a .csv file is stored in form of an excel the fields are populated based on the date written. Now my question is how can i write into a specific cell of the file. i.e, specific cell of the excel file.
Akhilesh Murthy wrote:As a .csv file is stored in form of an excel
No, a CSV file is a "comma-separated-value" file. That is, a plain text file that uses commas (or some other delimiter) do separate one field from another.
the fields are populated based on the date written. Now my question is how can i write into a specific cell of the file. i.e, specific cell of the excel file.
As I said: Read the file, find the appropriate place, change what you need to change, write the object model back out to the file.
This is the only way to do it; you can't just modify some part of the file directly, unless you a) know ahead of time the exact byte position of where you want to make the change AND b) the change you make will not use any more bytes than were already allocated for that field in that file. (And if it meets those conditions, then it's not really a CSV file.)
Now, there may be libraries out there--such as POI or a CSV manipulation library--that will abstract away the details of finding the cell and re-writing the entire file, so that you can just do something like setValue(row, column, value). If that's what you're looking for, see the link in the first reply.