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

Date problem #122

Open
eduardacenteno opened this issue Feb 9, 2021 · 2 comments
Open

Date problem #122

eduardacenteno opened this issue Feb 9, 2021 · 2 comments
Labels

Comments

@eduardacenteno
Copy link

Hey,
I recently installed odmltables, and I was just running a quick test. I created a template.xls using the GUI and tried to convert it to odml (without changing anything). However, I keep on getting this issue:

An error occurred. This is the full error report:

Traceback (most recent call last):
File "C:\Users\eduar\Desktop\python\Bordeaux\Elephant_Course\python-odmltables\odmltables\gui\converterpages.py", line 1064, in handlebuttonbrowse
convert(self.settings)
File "C:\Users\eduar\Desktop\python\Bordeaux\Elephant_Course\python-odmltables\odmltables\gui\converterpages.py", line 1299, in convert
table.write2odml(settings.get_object('outputfilename'))
File "C:\Users\eduar\Desktop\python\Bordeaux\Elephant_Course\python-odmltables\odmltables\odml_table.py", line 830, in write2odml
doc = self.convert2odml()
File "C:\Users\eduar\Desktop\python\Bordeaux\Elephant_Course\python-odmltables\odmltables\odml_table.py", line 792, in convert2odml
setattr(doc, doc_attr_name, doc_attr_value)
File "C:\Users\eduar\anaconda3\envs\metadataenv\lib\site-packages\odml-1.5.1-py3.9.egg\odml\doc.py", line 118, in date
new_value = dtypes.date_set(new_value)
File "C:\Users\eduar\anaconda3\envs\metadataenv\lib\site-packages\odml-1.5.1-py3.9.egg\odml\dtypes.py", line 258, in date_get
return dt.datetime.strptime(string, FORMAT_DATE).date()
TypeError: strptime() argument 1 must be str, not float

It goes away if I remove the date of creation of the xls (first row).
I tried several things, changing the cell format, the way it was written, but then complains about not following the %Y-%m-%d

@mdenker
Copy link
Member

mdenker commented Feb 9, 2021

Hi, thanks for finding this.

Indeed, the date value in the xls top row is formatted as a date when writing the template, but upon reading the file back in, it is intepreted as a float (not a string).

As I understand, in the past, the date was encoded differently in the xls on writing. Indeed, older xls files still convert fine. However, taking an older xls file, and setting the date field to be of type 'date' in libreoffice, leads to the same problem reported here. So I assume, this is probably a change of behavior in the xlwt library.

A quick fix: Take the template.xls and in Excel/Libreoffice, set the type of the date field to "Text".

@mdenker mdenker added the bug label Feb 9, 2021
@eduardacenteno
Copy link
Author

Hi @mdenker,
great, thanks! Changed the cell to text and inverted it to YYYY-MM-DD (coming as DD-MM-YYYY, possibly config of my excel) and now it works :)

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

No branches or pull requests

2 participants