Reputation: 5236
I have a scenario where data is read from a database and written to a csv file. The data has 3 columns Name
, Date
and Price
.If the csv doesn't exist, a new file is created and the data is written. If the csv does exist, I have to insert the data relative to the Date
data already in the csv. How can I go about doing this?
Upvotes: 0
Views: 275
Reputation: 8151
Easiest way is to parse your csv back in a datastructure, append the data from the database and sort on the date. Then overwrite the file with the sorted data.
Upvotes: 1