❔ changing values in .csv file with file i/o commands
hello, i'm trying to replace a certain column in a csv file with file i/o commands but i can't quite find out how to
10 Replies
Here's an example of the .csv file
You'd need to open a
FileStream
on this file to change the contents. Something like a StreamWriter
( or one of its implementations) would then allow you to write in it
Though keep in mind that might become a bit messy considering you'll need to keep the same order of all entries to not mess with data integrity.
Creating an entirely new file and removing/archiving the old one might be easier and safer unless neededWould that be a better option? (the creating a new file one)
also is there a way to directly replace a file with another file if i do it this way?
Directly, maybe, not sure since im not behind a PC to google :p
But basically:
1. Create new file.
2. Delete (or rename) old file
3. Rename new file to old name.
4. Delete old file if you havent yet.
ohh okay
Id think its better as you can ensure the file is only replaced once your edited file is done, though it depends on your situation
i'll try that, thank you so much <3
Np, good luck 😄
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.