python - Reading in csv file to pandas fails -


i have csv file generated exporting tableau table csv, can not manage open in python.

i have tried use pd.read_csv fails.

import pandas pd  #path file path = "tableau_crosstab.csv"  data = pd.read_csv(path, encoding="iso-8859-1")  

this works reading in file, result number of rows 1 character per row, , weird characters in head of frame.

ÿþd o     m         

and on. when try import file in excel have select tab separator, when trie here fails

import pandas pd  #path file path = "tableau_crosstab.csv"  data = pd.read_csv(path, encoding="iso-8859-1", sep='\t')  

cparsererror: error tokenizing data. c error: expected 1 fields in line 7, saw 2

i did try open file codecs, , says encoding 'cp1252', using encoding fails too.

i tried read in using utf-8 , fails. running out of ideas how solve this.

here link copy if file if take http://www.mediafire.com/file/6dtxo2deczwy3u2/tableau_crosstab.csv

you have unicode bom utf-16le

try

data = pd.read_csv(path, encoding="utf-16", sep='\t')  

the funny characters see: ÿþ corresponds hex ff fe unicode-16 little endian byte order mark. if see wikipedia page shows various byte order marks

i following when reading csv:

in[4]: data = pd.read_csv(r'c:\tableau_crosstab.csv', encoding='utf-16', sep='\t') data  out[4]:         domain month of date impressions clicks 0    test1.no        jun.17     725 676    633 1    test1.no        mai.17     422 995    456 2    test1.no        apr.17     241 102    316 3    test1.no        mar.17     295 157    260 4    test1.no        feb.17     122 902    198 5    test1.no        jan.17     137 972    201 6    test1.no        des.16     274 435    361 7   test2.com        jun.17   3 083 373  1 638 8   test2.com        mai.17   3 370 620  2 036 9   test2.com        apr.17   2 388 933  1 483 10  test2.com        mar.17   2 410 675  1 581 11  test2.com        feb.17   2 311 952  1 682 12  test2.com        jan.17   1 184 787    874 13  test2.com        des.16   2 118 594  1 738 14  test3.com        jun.17     411 456     41 15  test3.com        mai.17     342 048     87 16  test3.com        apr.17     197 058    108 17  test3.com        mar.17     288 949    156 18  test3.com        feb.17     230 970    130 19  test3.com        jan.17     388 032    115 20  test3.com        des.16   1 693 442    166 21   test4.no        jun.17     521 790    683 22   test4.no        mai.17     438 037    541 23   test4.no        apr.17     618 282  1 042 24   test4.no        mar.17     576 413    956 25   test4.no        feb.17     451 248    636 26   test4.no        jan.17     293 217    471 27   test4.no        des.16     641 491    978 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -