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

Error when patch and source files are almost empty #29

Closed kototama closed 7 years ago

kototama commented 7 years ago

Hello,

First, thank you for writing this tool. Very useful.

I got this error:

Traceback (most recent call last):
  File "/home/user/.local/bin/csvpatch", line 11, in <module>
    sys.exit(csvpatch_cmd())
  File "/home/user/.local/lib/python3.4/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/user/.local/lib/python3.4/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/user/.local/lib/python3.4/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/user/.local/lib/python3.4/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/user/.local/lib/python3.4/site-packages/csvdiff/__init__.py", line 218, in csvpatch_cmd
    patch_file(patch_stream, fromcsv_stream, tocsv_stream, strict=strict)
  File "/home/user/.local/lib/python3.4/site-packages/csvdiff/__init__.py", line 69, in patch_file
    fieldnames = from_records.fieldnames
AttributeError: 'generator' object has no attribute 'fieldnames'

when applying an empty patch file

{
  "_index": [
    "W",
    "B",
    "B2"
  ],
  "added": [],
  "changed": [],
  "removed": []
}

to an almost empty document:

"UE","W","B","B2","B3","UB",
larsyencken commented 7 years ago

Thanks for the report. I found the problem and put out a new release: https://pypi.python.org/pypi/csvdiff/0.3.2

kototama commented 7 years ago

Thank you very much.