1

I want to convert the '.csv' files to the '.hyper' file using python. so I found pantab. but when I run it, I’ve got a unicode error message.

example

import pandas as pd
import pantab

df = pd.DataFrame([
    ["dog", 4],
    ["cat", 4],
], columns=["animal", "num_of_legs"])

pantab.frame_to_hyper(df, "example.hyper", table="animals")

error code

File "C:\python\lib\site-packages\tableauhyperapi\impl\dllutil.py", line 27, in char_p_to_string
    return ffi.string(p).decode()

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb4 in position 0: invalid start byte.

Could you please explain me how to fix this?

이정훈
  • 11
  • 1
  • Hello, it looks like you are specifying the wrong table. Make `table="animal"`. Does that fix it? – Saddy Jan 03 '20 at 06:32
  • 1
    @Saddy, "animal" is the column name – Harshal Parekh Jan 03 '20 at 06:34
  • In that case, it is probably due to an invalid character in the file you are reading. See https://stackoverflow.com/questions/22216076/unicodedecodeerror-utf8-codec-cant-decode-byte-0xa5-in-position-0-invalid-s?noredirect=1 – Saddy Jan 03 '20 at 06:38
  • Hello, note that you do not need pantab to do the conversion from `.csv` to `.hyper`. You can directly use the HyperAPI as shown in this example: https://help.tableau.com/current/api/hyper_api/en-us/docs/hyper_api_insert_csv.html – jkammerer Jan 08 '20 at 13:41
  • The trace back suggests the error is coming from the tableauhyperapi so I don’t think @jkammerer suggestion will help. What version of the Hyper API do you have installed? – Will Ayd Jan 09 '20 at 02:53

0 Answers0