Modify ↓
#12813 closed defect (cantfix)
TypeError: unsupported operand type(s) for -: 'unicode' and 'datetime.datetime'
Reported by: | Owned by: | Jun Omae | |
---|---|---|---|
Priority: | normal | Component: | TicketImportPlugin |
Severity: | major | Keywords: | |
Cc: | sandeep.nadkarni@… | Trac Release: | 1.0 |
Description (last modified by )
Getting unicode and datetime.datetime error while importing from xls/csv
Trac - 1.0.10. TicketImport Plugin - ticketimportplugin-15601 python 2.7.5 Centos 7.2
File "/usr/lib/python2.7/site-packages/trac/web/main.py", line 554, in _dispatch_request File "/usr/lib/python2.7/site-packages/trac/web/main.py", line 247, in dispatch File "build/bdist.linux-x86_64/egg/talm_importer/importer.py", line 86, in process_request File "build/bdist.linux-x86_64/egg/talm_importer/importer.py", line 130, in _do_import File "build/bdist.linux-x86_64/egg/talm_importer/importer.py", line 401, in _process File "build/bdist.linux-x86_64/egg/talm_importer/processors.py", line 153, in end_process_row File "build/bdist.linux-x86_64/egg/talm_importer/processors.py", line 122, in _save_ticket File "/usr/lib/python2.7/site-packages/trac/ticket/model.py", line 306, in save_changes File "/usr/lib/python2.7/site-packages/trac/ticket/model.py", line 376, in _to_db_types File "/usr/lib/python2.7/site-packages/trac/util/datefmt.py", line 186, in to_utimestamp
Attachments (0)
Change History (6)
comment:1 Changed 8 years ago by
Component: | SELECT A HACK → TicketImportPlugin |
---|---|
Description: | modified (diff) |
Owner: | set to Jun Omae |
Priority: | high → normal |
Status: | new → assigned |
comment:2 Changed 8 years ago by
Resolution: | → cantfix |
---|---|
Status: | assigned → closed |
comment:3 Changed 7 years ago by
In file /usr/lib/python2.7/site-packages/trac/ticket/model.py change function _to_db_types to something like
def _to_db_types(self, values): values = values.copy() for field, value in values.iteritems(): if field in self.time_fields: is_custom_field = field in self.custom_fields if is_custom_field and value != '' and type(value) == unicode: values[field] = str(int(datetime.datetime.strptime(value, '%m/%d/%Y').strftime("%s"))) + "000000" else: values[field] = value if value else None return values
Change '%m/%d/%Y' to whatever format you use in your csv.
comment:4 Changed 4 years ago by
Resolution: | cantfix |
---|---|
Status: | closed → reopened |
Same Error, on a custom field named due_date, type time.
Importer settings:
[importer] csv_default_encoding = utf-8 datetime_format = %Y-%m-%d
local variables:
dt u'2018-12-31'
comment:5 Changed 4 years ago by
Resolution: | → cantfix |
---|---|
Status: | reopened → closed |
datetime_format
option is for date type in excel format. It is unable to use for time
field since Trac 1.2.
This issue is reported with Trac 1.0, not 1.2. Please create new ticket if you want to enhance for the time
field since Trac 1.2.
Note: See
TracTickets for help on using
tickets.
time
andchangetime
columns cannot be imported from Excel/CSV file.Please provide how to reproduce and Excel/CSV file if you don't use
time
andchangetime
columns.