mbrenig / SheetSync

A python library to create, update and delete rows of data in a google spreadsheet.
http://sheetsync.readthedocs.org
MIT License
48 stars 18 forks source link

Error handling for duplicate column header values is broken. #10

Open raids opened 9 years ago

raids commented 9 years ago

Hi there,

I receive the following error when performing .data() on a sheet which has 2 columns with the same value:

Traceback (most recent call last):
  File "read/read_data.py", line 15, in <module>
    key_column_headers=["AWS Account"])
  File "/Users/raid/Projects/sheetsync/venv/lib/python2.7/site-packages/sheetsync/__init__.py", line 413, in __init__
    self._get_or_create_headers()
  File "/Users/raid/Projects/sheetsync/venv/lib/python2.7/site-packages/sheetsync/__init__.py", line 706, in _get_or_create_headers
    self.header.set(cell.col, cell.value)
  File "/Users/raid/Projects/sheetsync/venv/lib/python2.7/site-packages/sheetsync/__init__.py", line 227, in set
    self.header_row_ix,  self.sheet_name))
AttributeError: 'Header' object has no attribute 'header_row_ix'

I guess this is because python dictionaries don't support duplicate keys, but is there any way duplicate column header values can be handled?

Cheers!

mbrenig commented 9 years ago

Right. There's no way to figure out which column to use (put data in, read data from) when you have duplicated column headers.

I can fix the error though, which is simple bug caused by the refactoring. Will roll that up with other fixes in the future.

Thanks!

XSchelin commented 7 years ago

Even something that returns a more accurate error message would be sufficient.