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 8556907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:27:22+00:00 2026-06-11T15:27:22+00:00

I have asked a similar question like this before but I am going to

  • 0

I have asked a similar question like this before but I am going to try again because I have some more questions.

I have two csv files that have 3 columns.

Name Product Amount:

I want to get the differences between the two files. I can do this if the two files are in the same order of name and product. This will give me the differences of amount which is what I am looking for.

I am needing to have something that will take to list and compare the two and show differences if not in same order.

I have tried:

import csv
import difflib 


file1 = open('file1','rb').read().splitlines()
file2 = open('file1','rb').read().splitlines()

for diff in difflib.ndiff(file1, file2):
    print(diff)

But if any thing is out of order no good. Is there a way I can group each “name product amount” and compare to file 2 where I have grouped each “name product amount”, and if there is a difference between file 1 and file 2 show that.

  • 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-11T15:27:24+00:00Added an answer on June 11, 2026 at 3:27 pm

    You can sort the lines using the python builtin function sorted(alist) or sort them inplace, using alist.sort().

    Also, you can use the UNIX command sort on the files before you open them in python. That way you can be sure they are both in order.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry I know similar question have been asked many times before but like most
Similar questions have been asked before but after a day of going through the
I had asked a question similar to this before, but I have a new
This is a similar question to those that have been asked before, but still
I have asked a question similar to this in the past but this is
I know similar questions have been asked before, but I've tried many times and
Various incarnations of this question have been asked here before, but I thought I'd
Similar questions have been asked over and over but for some reason none of
I know similar questions have been asked before, but still things are not clear
I know similar questions have been asked before, but I think my solution is

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.