-
-
Notifications
You must be signed in to change notification settings - Fork 166
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
Even if the format is a string it is displayed as a float #29
Comments
which file format is it? and is the file written by pyexcel? |
Yes the file is written with pyexcel The file format is ods |
are you using pyexcel-ods3 or pyexcel-ods? |
pyexcel-ods3 |
|
In addition, you could do pip install pyexcel-text, which replaces text-table as presentation library
|
Oh.. sorry, I have noticed that you have it displayed correctly but just the presentation got it wrong. I started to understand your problem now. |
Initially we have this
with '0123' and '04566651561653122' as a string ! But when we display it we get
No more 0 And
We have 4.567e+15 instead of 04566651561653122, the print considers those strings as float |
reproduced.
|
Hi, When do you think this bug will be solved ? In the next release ? |
Will be in in v0.2.1 branch. I have the initial fix and will push it up tonight. |
Could you please evaluate the fix?
|
Hi, this fix gave me this:
instead of something like this :
Off course we don't have anymore the problem of string or float, but where is the table ? We don't have the table anymore. the table is printed like a text with tabulation, this is not what we've expected. |
To summuarize This is what originally I have with pyexcel 0.2.0
And this is what is expected
Because we have this:
'0123' and '04566651561653122' are string and not float or int however this is what pyexcel v0.2.1 (not released) give
There is no more problem of float or string with '0123' and '04566651561653122' but there is no table |
In short, please do pip uninstall pyexcel-text. This is new thing in v0.2.1. Long answer, v0.2.1 does auto import on pyexcel-text. The way you can manage it is to use pip to add/remove pyexcel-plugins(pyexcel/pyexcel-io#7). And the same thing will happen to pyexcel-ods3 in its version 0.2.0 release. The benefit is that no longer, a developer needs to do explicit import. |
And I am sorry that I should have informed you about the new feature in v0.2.1 3 days ago. |
After doing pip3 uninstall pyexcel-text it gave me this:
So I think that the bug is solved in this version. However, I have a question, what if a user wants to use both of pyexcel-text and pyexcel-ods3 ? it is more and more difficult to know which package to install, then uninstall |
pyexcel-text modifies the default string presentation of pyexcel sheet, which is an additional functionality that other pyexcel plugins do not do. It does become a problem when the user of pyexcel does not want presentation modification but still needs pyexcel-text for text file writing. Let me think about the solution. |
Will provide a solution for #31 before I release v0.2.1 |
I remarked something strange in this version 0.2.1. When we put a number as an int, if we print the table, it displays the number as an int. But, if we save the file then reopenning it, displays it as a float. It is strange. I'll open a new topic to explain in details. |
I did not try if there is the same bug with other libraries pyexcel-xls etc... |
with xls and xlsx, you will get float by default even though you have saved integer. with csv, you will get text(string). ods format, it is float but it seems there is a way around it. |
Now I tried with xls, it seems that the bug is fixed in the new version 0.2.1 for every file type
I'm not talking about this issue, but the bug described in this topic. I wanted to be sure that the bug has been fixed for every file type |
I see your point but xls uses xlrd, xlsx uses openxy and csv itself does not support data types other than string. So, these are outside the control of pyexcel unless pyexcel strives to rewrite those libraries. However, with the constraints, pyexcel have the facilities to normalize the types after reading them back through the underneath libraries. |
Here is a list of data types supported by xlrd, where integer isn't listed:
|
I'm not talking about integer here in this topic, but when a string is displayed as a float. Maybe you've mixed the two topics. |
Let me correct myself, with xlsx, you can save integer and get it back. for xls, you get float. csv, you get string. Here's what I have tried with(pyexcel=0.2.0 and other plugins were 0.1.x):
|
I see.. sorry about that... |
lol |
Here is the one talking about integers: |
this bug(string as float) is with pyexcel not with pyexcel-xls. the fix I did was to tell texttable that all content are of string type and I used to convert every type to string and then ask texttable to display all. |
Ok, that sounds good, so you can close this topic again lol |
An upddate: the fix is released with pyexcel v0.2.1. And to avoid confusion, pyexcel-text 0.2.0 is to work with v0.2.1. Previous version won't work at all with pyexcel v0.2.1. |
OK let's try it |
This a bug of display and very annoying, since even if a number (like serial number for example) is wirtten as a text into a table it is still displayed as a float,
Example:
'>>> ReportWorkbook = pe.get_book(file_name=rep_name)
'>>> ReportWorkbook['Infos']
Sheet Name: Infos
+-----------------+------------------+
| Date | 2016-03-31 10:59 |
+-----------------+------------------+
| Model name | XS360_EU |
+-----------------+------------------+
| Time by X | 60 |
+-----------------+------------------+
| Product A | 123 |
+-----------------+------------------+
| Product B | 4.567e+15 |
+-----------------+------------------+
| Bandwidth (UDP) | N/A |
+-----------------+------------------+
| Other infos | N/A |
+-----------------+------------------+
'>>> ReportWorkbook['Infos'].column[1]
['2016-03-31 10:59', 'XS360_EU', 60.0, '0123', '04566651561653122', 'N/A', 'N/A']
As seen above the serial numbers of products A and B are 0123 and 04566651561653122 are stocked as a text (string), however. Whend displayed with print they are displayed as a float so we se the first '0' disappear and 4.567e+15 insetead of 04566651561653122
The text was updated successfully, but these errors were encountered: