Python Forum
A simple problem, how best to solve it? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: A simple problem, how best to solve it? (/thread-40642.html)



A simple problem, how best to solve it? - SuchUmami - Aug-31-2023

This seems quite simple compared to many problems I've had. However, I'm not finding an elegant solution at the moment.

I have two csv files and I'd like to combine them and then write them to another csv file. My problem is that these csv files are constantly being updated and I don't want to miss out on any updates. If I combine a row of data and then save it to another csv file, I might have missed out on further updates to the csv file or I might miss a row of data if several get put into the first csv file at once. However if I simply combine all the rows with the current piece of data, I may have issues saving the new amended data to a csv file. There are various things that can go wrong.

Is there an easy way to do this that I'm not thinking of?


RE: A simple problem, how best to solve it? - deanhystad - Aug-31-2023

Do the files contain a timestamp? Synchronize on that. Otherwise, there is no synchronization and your combined file is meaningless.


RE: A simple problem, how best to solve it? - Pedroski55 - Sep-01-2023

Quote:these csv files are constantly being updated

If everything is constantly updating, you will just need to do this regularly. You will always miss something!

Set a cronjob to run your Python script every hour or whatever.