rogerlew / pyvttbl

Automatically exported from code.google.com/p/pyvttbl
10 stars 8 forks source link

DataFrame crashes with non-ascii characters in unicode strings #12

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Trying to use a unicode string that contains a non-ascii character, as a value 
on a record.

What is the expected output?

Successful instantiation of a DataFrame object

What do you see instead?

An exception caused by trying to convert a non-ascii unicode string into ascii:

Traceback (most recent call last):
  File "non_ascii_char_table_header.py", line 19, in <module>
    for col_name, col in zip(header, zip(*records))
  File "/home/jerojasro/.virtualenvs/zinobe_dashboard/local/lib/python2.7/site-packages/pyvttbl/base.py", line 86, in __init__
    super(DataFrame, self).update(*args, **kwds)
  File "/home/jerojasro/.virtualenvs/zinobe_dashboard/lib/python2.7/_abcoll.py", line 500, in update
    self[key] = value
  File "/home/jerojasro/.virtualenvs/zinobe_dashboard/local/lib/python2.7/site-packages/pyvttbl/base.py", line 347, in __setitem__
    __setitem__(key, np.array(item, dtype=self._get_nptype(key)))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xed' in position 1: 
ordinal not in range(128)

What version of the product are you using? On what operating system?

pyvttbl==0.5.2.2 , installed through pip, on Ubuntu Linux

Please provide any additional information below.

See attached files:

non_ascii_char_in_record.py : example code that causes the crash reported

string_encoding_patch : suggested patch to fix the issue

Original issue reported on code.google.com by javier.r...@axiacore.com on 5 Aug 2013 at 8:25

Attachments: