'I cannot read csv file as pandas dataframe (anymore)
I have just changed laptop (from Windows to Mac) and after reinstalling anaconda/spyder I have tried to run the same code that reads a csv file as a pandas dataframe.
I have been using: pd.read_csv (path file)
pd.read_csv("/User/Documents/etc...csv")
but the code gets stuck. It runs for several minutes and afterwards the console displays:
"Errno 5" Input/output error: '/User/Documents/....'.
Do you have an idea of which reason could be behind this?
Solution 1:[1]
You can try:
from pathlib import Path
pd.read_csv(Path("User/Documents/etc/file.csv"))
Solution 2:[2]
use two forward // instead of one like this import pandas as pd df=pd.read_csv("C//User/Documents/etc..//filename.csv")
Solution 3:[3]
I think your csv file is not correct format. May be use a spacial character. so you can try this code.
pd.read_csv("/User/Documents/etc...csv", encoding = "ISO-8859-1")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Rene |
| Solution 2 | KHURRAM |
| Solution 3 | Shiva Manhar |
