You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Obviously there is some shifting thing cuz the name should be text and the total should be numeric
I read the code :
1. offset, headers = messytables.headers_guess(row_set.sample)
2. types = messytables.type_guess(row_set.sample, types=TYPES, strict=False)
The first empty header would be stored as u'',It's totally fine.
Here len(types)==len(headers)
3. headers = [header.strip() for header in headers if header.strip()]
Then this line dropped the u'',but didn't drop correspond type, that is ,len(types)== len(headers) -1
4. `headers_dicts = [dict(id=field[0], type=TYPE_MAPPING[str(field[1])]) for field in zip(headers, types)]`
Finally in this line we get a wrong headers_dicts, zipfunc would not raise error even if parameters have different length.
The text was updated successfully, but these errors were encountered:
zyxbest
changed the title
I met bug when my csv header begins with comma
I met bug when my csv header began with comma
Jul 11, 2017
situation
When I upload a file like this,the first header is '' since the line begins with comma.(See the up left empty cell)
![image](https://user-images.githubusercontent.com/5809588/28064352-d8d33e8c-6666-11e7-8012-69b301c61a8d.png)
Then DataPusher raise error as
The data was invalid (for example: a numeric value is out of range or was inserted into a text field).
debug
The directly reason of the error is
headers_dicts
in DataPusher:I log the headers_dicts then it shows:
Obviously there is some shifting thing cuz the
name
should betext
and thetotal
should benumeric
I read the code :
1.
offset, headers = messytables.headers_guess(row_set.sample)
2.
types = messytables.type_guess(row_set.sample, types=TYPES, strict=False)
The first empty header would be stored as u'',It's totally fine.
Here len(types)==len(headers)
3.
headers = [header.strip() for header in headers if header.strip()]
Then this line dropped the u'',but didn't drop correspond type, that is ,len(types)== len(headers) -1
Finally in this line we get a wrong headers_dicts,
zip
func would not raise error even if parameters have different length.The text was updated successfully, but these errors were encountered: