pydata/pandas — Issue #835: When parsing a CSV file without an index, if the list with columns names is too short or too long, one gets a "Index contains duplicate entries" exception.
Author: aristotle137
Created: 2012-02-27 13:20:57+00:00
State: open

Hi Wes,

Just a minor bug submisson:
When parsing a CSV file without an index, if the list with columns names is too short or too long, one gets a "Index contains duplicate entries" exception.

E.g.:

The file test.csv contains:
abc,1,a
abc,2,b
def,3,c

Running:
```table = pandas.read_csv('reports/9/test.csv', header=None, names=['a', 'b'],index_col=None)```

Results in:
---------------------------------------------------------------------------
```python
Exception Traceback (most recent call last)
/home/marius/Code/otsquant/analysis/ccapital/ in ()
----> 1 table = pandas.read_csv('reports/9/test.csv', header=None, names=['a', 'b'],index_col=None)

/usr/lib64/python2.7/site-packages/pandas/io/parsers.pyc in read_csv(filepath_or_buffer, sep, header, index_col, names, skiprows, na_values, parse_dates, date_parser, nrows, iterator, chunksize, skip_footer, converters, verbose, delimiter, encoding)
125 return parser
126
--> 127 return parser.get_chunk()
128
129 @Appender(_read_table_doc)

/usr/lib64/python2.7/site-packages/pandas/io/parsers.pyc in get_chunk(self, rows)
467 if not index._verify_integrity():
468 dups = index.get_duplicates()
--> 469 raise Exception('Index has duplicates: %s' % str(dups))
470
471 if len(self.columns) != len(zipped_content):

Exception: Index has duplicates: ['abc']
```

Many thanks,
Marius