Answer the question
In order to leave comments, you need to log in
Is it possible to change a specific row in a CSV file?
There is a database of store products in a CSV file. You need to check each row for updates. Passed the line -> there is a change -> overwrote the line without touching the rest.
How data is stored in CSV (with example):
item_id; item_ean; item_name; item_price
1; 121hggh;Table; 2300
Answer the question
In order to leave comments, you need to log in
Not enough data to think about. Even if the option is standard Base and CSV import, then not everything is clear.
If there is a key field, then there is no problem. If not, then everything is somewhat more complicated, sometimes even impossible. Can you give me a little more information about the database and CSV?
And what prevents you from acting like a white man, that is, parsing CSV, looping through it and correcting the necessary values, and then writing this data back to a file?
In the end, if the file is huge (hundreds of megabytes), you can read, edit and write it line by line. Although, to optimize the work with the disk, it is better not to have one line, but ten (depending on how long the line is).
Yes, the script will work on a huge file for a long time, maybe even a few minutes. But files are what they are. Need speed - take the database.
It is theoretically possible to correct only one value, but you will not get hemorrhoids. For example, imagine a situation where you need to not just change a couple of bytes, but add them to the middle of a file.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question