larsyencken / csvdiff

Generate a diff between two tabular datasets expressed in CSV files.
BSD 3-Clause "New" or "Revised" License
132 stars 31 forks source link

diff = csvdiff.diff_files('output.txt', 'input.txt',[]) #39

Closed karakutu001 closed 5 years ago

karakutu001 commented 6 years ago

I am trying to run in basic form this module.

import csvdiff

diff = csvdiff.diff_files('output.txt', 'input.txt',[])

print(diff)

I am a littel bit confused. i am getting following errors:

"/python/test.py" Traceback (most recent call last): File "XXXX/python/test.py", line 4, in diff = csvdiff.diff_files('output.txt', 'input.txt',[]) File "C:\Users\DDDDD\AppData\Roaming\Python\Python37\site-packages\csvdiff__init__.py", line 44, in diff_files ignore_columns=ignored_columns) File "C:\Users\DDDDD\AppData\Roaming\Python\Python37\site-packages\csvdiff\patch.py", line 211, in create return create_indexed(from_indexed, to_indexed, index_columns) File "C:\Users\DDDDD\AppData\Roaming\Python\Python37\site-packages\csvdiff\patch.py", line 222, in create_indexed index_columns) File "C:\Users\DDDDD\AppData\Roaming\Python\Python37\site-packages\csvdiff\patch.py", line 252, in _assemble key=_change_key) File "C:\Users\DDDDD\AppData\Roaming\Python\Python37\site-packages\csvdiff\patch.py", line 251, in for k in changed), File "C:\Users\DDDDD\AppData\Roaming\Python\Python37\site-packages\csvdiff\patch.py", line 264, in recorddiff from = lhs[k] KeyError: 'CAFEE01'

Process finished with exit code 1

larsyencken commented 5 years ago

Hey. So the diff requires one or more index columns to act as primary keys. That way you can identify records which are the same, but have been modified. Try again with index columns.