2

I try to read csv file

 df = pd.read_csv("raccoons.csv", delimiter=":")
 df.head()

and it returns to me

 ��c    Unnamed: 1  Unnamed: 2
 NaN    NaN     NaN     NaN
 NaN    NaN     NaN     NaN
 NaN    NaN     NaN     NaN
 NaN    NaN     NaN     NaN
 NaN    NaN     NaN     NaN

inside of file

corrds:time:raccoons_bought
55.771393 37.567392:4423O3138:2
55.705458 37.550926:442365718:0
55.83028 37.404815:442244596:0
55.799092 37.452157:442327511:148.00001
55.749785 37.763962:442248573:1
Anton
  • 209
  • 2
  • 6
  • 15

2 Answers2

5

It probably has to do with the file encoding. You may have to set this when calling read_csv. Check the solutions to find your file encoding provided here: UnicodeDecodeError when reading CSV file in Pandas with Python

I had this same issue and finally solved it using:

pd.read_csv(..., encoding = 'utf-16')
Jaime
  • 51
  • 1
  • 3
0

Try:

import pandas as pd
path = r"raccoons.csv"
df = pd.read_csv(path, sep=":",dtype=None)
print(df)

Answer edited. It worked for me!

Ardit
  • 1,522
  • 17
  • 23
  • ��c object Unnamed: 1 object Unnamed: 2 object dtype: object. I try dtype float, object - it doesn't help – Anton Sep 22 '17 at 10:31
  • i was try to replace ' ' and ':' to ',' but it still doesn't help. i was try R notebook, try python3, python2 it all doesn't help me. – Anton Sep 22 '17 at 10:32
  • 1
    I recreated on ubuntu 17:04 with python 2.7, worked like a charm. My tip would be to check the encoding of your csv file. looks like that for me `$ file -i racoons.csv racoons.csv: text/plain; charset=us-ascii` – Johannes Reichard Sep 22 '17 at 10:43
  • seems problem in lines like that 55.64824 37.668399:442O42976:"""5""" and 55.769347 37.567509:442317124:1e-05 or not! I create file with 5 first strings result as always -> NAN((( – Anton Sep 22 '17 at 10:55
  • i copied values and pasted in new file it solve my problem, thanks you all for help! – Anton Sep 22 '17 at 11:06