bottom-up-attention icon indicating copy to clipboard operation
bottom-up-attention copied to clipboard

read_tsv file error

Open ntubertchen opened this issue 8 years ago • 7 comments

when I use default setting, which r+b, to open tsv file, error occurs like _csv.Error: iterator should return strings, not bytes (did you open the file in text mode?) in line "for item in reader:" when I use r+ TypeError: expected bytes-like object, not str. occur at np.frombuffer(base64.decodestring(item[field]), my environment in windows. should it matter?

ntubertchen avatar Jul 10 '18 03:07 ntubertchen

I'm afraid none of this is tested on windows, you might have to do your own research on this one, sorry!

peteanderson80 avatar Jul 10 '18 07:07 peteanderson80

I faced the same issue in Ubuntu-GNOME. Later, I found out that this TypeError is not necessarily caused because of the OS platform but it's due to the Python version itself. This error appears for Python 3.x versions; Try to run the script as is using Python 2:

python2 read_tsv.py

And that should work!

kmario23 avatar Sep 14 '18 11:09 kmario23

which proto have you used? Thanks.

gulugulujiang avatar Nov 09 '18 14:11 gulugulujiang

after 1.changing the open mode to "r" or "rt": with open(infile, "r") as tsv_in_file 2.changing base64.decodestring(item[field]) to base64.decodebytes(bytes(item[field], encoding="utf8")) It can work.

njucckevin avatar Feb 16 '20 16:02 njucckevin

after 1.changing the open mode to "r" or "rt": with open(infile, "r") as tsv_in_file 2.changing base64.decodestring(item[field]) to base64.decodebytes(bytes(item[field], encoding="utf8")) It can work. image

these are boxes extracted from the file, the number looks so weirdly large, did you get the same as i am?

maoyj2333 avatar Jun 07 '21 02:06 maoyj2333

code from Ruotian Luo this code seems work well image

maoyj2333 avatar Jun 07 '21 03:06 maoyj2333

after 1.changing the open mode to "r" or "rt": with open(infile, "r") as tsv_in_file 2.changing base64.decodestring(item[field]) to base64.decodebytes(bytes(item[field], encoding="utf8")) It can work. image

these are boxes extracted from the file, the number looks so weirdly large, did you get the same as i am?

As far as I can remember, my boxes feature don't have this problem, it just like the result of Ruotian Luo. But I don't have the source tsv file now, so I'm not very sure.

njucckevin avatar Jun 07 '21 03:06 njucckevin