Opened 6 years ago

Closed 6 years ago

Last modified 17 months ago

#8804 closed defect (fixed)

AttributeError: 'float' object has no attribute 'strip'

Reported by: ruedi.silvestri@… Owned by: farialima
Priority: low Component: TicketImportPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.12


I got successfully TicketImportPlugin 0.8 and xlrd 0.7.1 install. Though trying to upload a Excel 2003 format xls results to an "AttributeError: 'float' object has no attribute 'strip'" exception.

Datei "build/bdist.win32/egg/trac/web/", Zeile 517, in _dispatch_request
Datei "build/bdist.win32/egg/trac/web/", Zeile 238, in dispatch
Datei "build/bdist.win32/egg/talm_importer/", Zeile 77, in process_request
Datei "build/bdist.win32/egg/talm_importer/", Zeile 121, in _do_preview
Datei "build/bdist.win32/egg/talm_importer/", Zeile 348, in _process 

Attachments (1)

celltypes.xls (18.5 KB) - added by jun66j5 6 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 6 years ago by ruedi.silvestri@…

  • Priority changed from high to low
  • Severity changed from major to normal

I just identified the issues being caused by having blanks in the file name I tried to upload. Maybe it would help to catch this exception with a respective error message as a workaround.

Thanks, Ruedi.

comment:2 Changed 6 years ago by ruedi.silvestri@…

please ignore the above comment about the filename. I managed to identify the cause which was origined by a text value in a cell which is supposed to be a number. Actually it would be good to make below extensions:

1) validate format of source value and raise exceptions if issues found. 2) pure number values seem automatically to be considered as floating numbers. Though on some reference numbers one would not want to have the number suffixed by .0 by the import.

Regards, Ruedi.

comment:3 follow-up: Changed 6 years ago by farialima


Could you attach a .xls file that shows the problem to this ticket ? I don't have Excel 2003 and it will save me some time....

Thanks for reporting and for investigating !

comment:4 in reply to: ↑ 3 Changed 6 years ago by jun66j5

I attach Excel 2003 file which contains text, number, date, boolean and error cells, celltypes.xls. When excel file has boolean and error cells other than number cells, the same issue occurs.

The following patch; convert the value to string for each cell type.

  • talm_importer/

    102102            row = {}
    103103            i = 0
    104104            for cx in xrange(
    105                 row[header[i]] =, cx)
    106                 if, cx) == xlrd.XL_CELL_DATE:
    107                     row[header[i]] = datetime.datetime(*xlrd.xldate_as_tuple(row[header[i]],
     105                val =, cx)
     106                cell_type =, cx)
     107                if cell_type == xlrd.XL_CELL_NUMBER:
     108                    val = '%g' % val
     109                elif cell_type == xlrd.XL_CELL_DATE:
     110                    val = datetime.datetime(*xlrd.xldate_as_tuple(val,
     111                    val = val.strftime(self._datetime_format)
     112                elif cell_type == xlrd.XL_CELL_BOOLEAN:
     113                    val = ('FALSE', 'TRUE')[val]
     114                elif cell_type == xlrd.XL_CELL_ERROR:
     115                    val = xlrd.error_text_from_code.get(val) or '#ERR%d' % val
     116                row[header[i]] = val
    109118                i += 1
    110119            data.append(row)

Changed 6 years ago by jun66j5

comment:5 Changed 6 years ago by jun66j5

  • Resolution set to fixed
  • Status changed from new to closed

(In [10230]) fixed #8804, convert value of cell which is number, boolean or error cell to string.

Add Comment

Modify Ticket

as closed The owner will remain farialima.
The resolution will be deleted. Next status will be 'reopened'.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.