TabViewer / gtabview

Simple graphical tabular data viewer
MIT License
33 stars 3 forks source link

Passing encoding to Blaze URI's #17

Closed firecat53 closed 9 years ago

firecat53 commented 9 years ago

Hey, I'm just starting to look at incorporating your work on Blaze into tabview (firecat53/tabview#127) and was wondering if there's a way to pass the encoding on to Blaze?

Trying gtabview file:///path/to/tabview/samples/test_latin1.csv gives:

Traceback (most recent call last):
  File "/home/firecat53/.local/share/virtualenvs/gtabview/bin/gtabview", line 4, in <module>
    __import__('pkg_resources').run_script('gtabview==0.4', 'gtabview')
  File "/home/firecat53/.local/share/virtualenvs/gtabview/lib/python3.4/site-packages/pkg_resources/__init__.py", line 735, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/home/firecat53/.local/share/virtualenvs/gtabview/lib/python3.4/site-packages/pkg_resources/__init__.py", line 1652, in run_script
    exec(code, namespace, namespace)
  File "/home/firecat53/.local/share/virtualenvs/gtabview/lib/python3.4/site-packages/gtabview-0.4-py3.4.egg/EGG-INFO/scripts/gtabview", line 94, in <module>
    transpose=args.transpose, metavar=args.filename)
  File "/home/firecat53/.local/share/virtualenvs/gtabview/lib/python3.4/site-packages/gtabview-0.4-py3.4.egg/gtabview/__init__.py", line 178, in view
    data = blaze_from_uri(data)
  File "/home/firecat53/.local/share/virtualenvs/gtabview/lib/python3.4/site-packages/gtabview-0.4-py3.4.egg/gtabview/__init__.py", line 125, in blaze_from_uri
    return blaze.Data(uri)
  File "/home/firecat53/.local/share/virtualenvs/gtabview/lib/python3.4/site-packages/blaze/interactive.py", line 56, in Data
    **kwargs)
  File "/home/firecat53/.local/share/virtualenvs/gtabview/lib/python3.4/site-packages/odo/regex.py", line 64, in __call__
    return self.dispatch(s)(s, *args, **kwargs)
  File "/home/firecat53/.local/share/virtualenvs/gtabview/lib/python3.4/site-packages/odo/backends/csv.py", line 278, in resource_csv
    return CSV(uri, **kwargs)
  File "/home/firecat53/.local/share/virtualenvs/gtabview/lib/python3.4/site-packages/odo/backends/csv.py", line 104, in __init__
    infer_header(path, sniff_nbytes))
  File "/home/firecat53/.local/share/virtualenvs/gtabview/lib/python3.4/site-packages/odo/backends/csv.py", line 60, in infer_header
    return csv.Sniffer().has_header(raw if PY2 else raw.decode(encoding))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xae in position 460: invalid start byte

Trying to pass the encoding with -e doesn't seem to help. Ideas?

Thanks, Scott

s-celles commented 9 years ago

Maybe @cpcloud or @llllllllll can help on this

What version of Python are you using ?

llllllllll commented 9 years ago

It looks like we are not forwarding the encoding to the csv header check. I will update this.

llllllllll commented 9 years ago

I have a fix that allows us to open this file when encoding=latin1 is passed to resource, Data or CSV