Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7781293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:10:53+00:00 2026-06-01T19:10:53+00:00

Background : With a Python Script, I scraping data (html) from a Website and

  • 0

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
*

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T19:10:55+00:00Added an answer on June 1, 2026 at 7:10 pm

    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:

    >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(1),
    ...              'ore\ntree\nemu\n'.splitlines(1))
    >>> diff = list(diff) # materialize the generated delta into a list
    >>> print ''.join(restore(diff, 1)),
    one
    two
    three
    >>> print ''.join(restore(diff, 2)),
    ore
    tree
    emu
    

    To print the changes to a file:

    >>> s1 = ['bacon\n', 'eggs\n', 'ham\n', 'guido\n']
    >>> s2 = ['python\n', 'eggy\n', 'hamster\n', 'guido\n']
    >>> for line in unified_diff(s1, s2, fromfile='before.py', tofile='after.py'):
    ...     sys.stdout.write(line)   
    --- before.py
    +++ after.py
    @@ -1,4 +1,4 @@
    -bacon
    -eggs
    -ham
    +python
    +eggy
    +hamster
     guido
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background I would like my Python script to pause before exiting using something similar
I need to run a Python script in the background after being called from
I'm making a python script that should run in the background and notify a
I want to launch a background Python job from a bash script and then
The background: I've written a python script to inspect IP packets, specifically the payload/data
I'm coming to learn Perl from a Python background where the following hash-to-string conversion
I'm new to C# coming from a python background. I've had a hard time
I´m trying to learn C#, coming from a Python/PHP background, and I´m trying to
I'm moving from a PHP background into Django development via python, mostly for the
I'm very new to Python (I'm coming from a JAVA background) and I'm wondering

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.