Background : With a Python Script, I scraping data (html) from a Website and put this data in a CSV document.
This CSV document looks like that :
Hong Kong;The Jardine Engineering Corporation Limited
Hong Kong;Towngas
Hong Kong;Tricor Services Limited
Hong Kong;UL International Limitied
Hong Kong;Urban Property Management Limited
Hong Kong;VTECH Corporate Services Ltd.
Vietnam;Cam Ranh Computer Co. Ltd
Vietnam;CFTP Company
Vietnam;Chevron Vietnam
First column : Country
Second column : Name
My file have more than 5000 rows.
I need to compare this CSV document, to another one (from the same script, so same structure) to track the potential changes (if we have new lines, or removed one). The best will be to create a file with all the changes, or print them in the terminal.
*REMEMBER that if something change in the CSV file (one more row) all the data gonna be shifted
*
Welcome to StackOverflow. 🙂
Your problem boils down to doing a diff between two lists. This is available in Python via difflib.
This example from the manual should help you:
To print the changes to a file: