0

I am working with stock data which i download using a file everyday. The file contains the same no of columns everyday but the rows would change everyday depending up the stocks in and out of the list. I am looking to compare the files from 2 dates and find the difference between the total quantity column. I want to see the difference between the two files which stocks got in or got out of the list.

I have tried using pandas dataframe and storing it in a hd5 file. Then tried merge function of the dataframes to find the differences between the two file. I am looking for a much elegant solution so that i can compare data frames and find the differences like i do it using index and match(or vlookup) function of excel.

Neetesh
  • 131
  • 1
  • 1
  • 3
  • In what format is the file you receive ? – Nick Apr 18 '19 at 14:07
  • 1
    This is very broad. To get any meaningful answer you should include file types, sample input / output, why you think your current solution is inelegant etc. – Geekfish Apr 18 '19 at 14:11

1 Answers1

0

You should use the python difflib library to compare the files.

From the documentation:

This module provides classes and functions for comparing sequences. It can be used for example, for comparing files, and can produce difference information in various formats, including HTML and context and unified diffs

Also, look at the answers to this similar question for some examples. One example that may be useful in your case is this one.

Nick
  • 3,454
  • 6
  • 33
  • 56