Skip to content
This repository has been archived by the owner on Feb 18, 2021. It is now read-only.

KeyError when comparing csv files #60

Open
CaptainDaVinci opened this issue Oct 6, 2020 · 1 comment
Open

KeyError when comparing csv files #60

CaptainDaVinci opened this issue Oct 6, 2020 · 1 comment

Comments

@CaptainDaVinci
Copy link

I have the following 2 csv files,

view-1.csv

As of Date,Business Title,Email,Employee Type,Employee_ID

view-2.csv

'As of Date',As of Date,Business Title,Email,Employee Type,Employee_ID

Running

$ csvdiff Employee_ID view-1.csv view-2.csv 

Throws the following error,

Traceback (most recent call last):
  File "/Users/.pyenv/versions/3.7.5/bin/csvdiff", line 8, in <module>
    sys.exit(csvdiff_cmd())
  File "/Users/.pyenv/versions/3.7.5/lib/python3.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/Users/.pyenv/versions/3.7.5/lib/python3.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/Users/.pyenv/versions/3.7.5/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/.pyenv/versions/3.7.5/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/Users/.pyenv/versions/3.7.5/lib/python3.7/site-packages/csvdiff/__init__.py", line 160, in csvdiff_cmd
    significance=significance)
  File "/Users/.pyenv/versions/3.7.5/lib/python3.7/site-packages/csvdiff/__init__.py", line 172, in _diff_files_to_stream
    diff = diff_files(from_csv, to_csv, index_columns, sep=sep, ignored_columns=ignored_columns)
  File "/Users/.pyenv/versions/3.7.5/lib/python3.7/site-packages/csvdiff/__init__.py", line 44, in diff_files
    ignore_columns=ignored_columns)
  File "/Users/.pyenv/versions/3.7.5/lib/python3.7/site-packages/csvdiff/patch.py", line 211, in create
    return create_indexed(from_indexed, to_indexed, index_columns)
  File "/Users/.pyenv/versions/3.7.5/lib/python3.7/site-packages/csvdiff/patch.py", line 222, in create_indexed
    index_columns)
  File "/Users/.pyenv/versions/3.7.5/lib/python3.7/site-packages/csvdiff/patch.py", line 252, in _assemble
    key=_change_key)
  File "/Users/.pyenv/versions/3.7.5/lib/python3.7/site-packages/csvdiff/patch.py", line 251, in <genexpr>
    for k in changed),
  File "/Users/.pyenv/versions/3.7.5/lib/python3.7/site-packages/csvdiff/patch.py", line 264, in record_diff
    from_ = lhs[k]
KeyError: "'As of Date'"

I was expecting the output to be something like columns removed/added: 1, 'As of Date'.

@larsyencken
Copy link
Owner

larsyencken commented Oct 6, 2020 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants