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 dat开发者_JAVA技巧a 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?
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.
精彩评论