Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some string-formatted values are importing as decimal values #31

Open
smcoll opened this issue Sep 24, 2014 · 2 comments
Open

Some string-formatted values are importing as decimal values #31

smcoll opened this issue Sep 24, 2014 · 2 comments

Comments

@smcoll
Copy link
Contributor

smcoll commented Sep 24, 2014

In an xlsx file, i have a column of string values, such as "66", "783 Foo". On import into a CharField, it seems that any value that can be interpreted as a decimal is converted to one, like "66.0", while other values like "783 Foo" remain as-is. The desired result is that the data is not reformatted that way.

@bufke
Copy link
Member

bufke commented Nov 22, 2014

This and your other issues are seem valid. There is a general problem of the user expects it to be imported one way but it gets imported another. With some exceptions the import does setattr(new_object, header_row_field_name, cell). And cell is whatever the library that opened the import file gives out. For more fun different libraries give different results. If you have any ideas to solve this let me know.

@smcoll
Copy link
Contributor Author

smcoll commented Nov 23, 2014

Wouldn't an importer be able to determine the cell type for most import formats? i suspect we could read the cell format and then compare against a mapping of python types.

One format which wouldn't have that kind of support is a csv. Since a csv can store decimals and integers without quotes, it should work fine unless cell is formatted as a decimal with commas as the thousands separator, as the whole number has to be enclosed in quotes. A tab-separated file wouldn't have this issue. Examples of csv and tsv for different column types: https://gist.github.com/smcoll/86359a58b6e166b36e4d

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

No branches or pull requests

2 participants