"CSV does not exist" - Pandas DataFrame

I find it difficult to read the csv file in the pandas data frame. I am a complete newbie to pandas and this is stopping me from developing. I read the documentation and searched for solutions, but I can not continue. I tried the following to no avail ...

import pandas as pd import numpy as np pd.read_csv('C:\Users\rcreedon\Desktop\TEST.csv') pd.read_csv("C:\Users\rcreedon\Desktop\TEST.csv") 

and similar permutations with / without quotes.

It spills out a big composite error that ends in:

 IOError: File C:\Users creedon\Desktop\TEST.csv does not exist 

It seems strange that in error he skips "r" from "rcreedon". Does this cause problems?

Just for the sake of this, I also tried

 pd.read_csv('C:\rcreedon\Desktop\TEST.csv') 

Again, β€œr” was skipped when an error was returned.

Sorry I'm such a block leader, but I'm afraid here ....

Any help appreciated.

+6
source share
3 answers

"\ r" is usually interpreted as a special character and means carriage return. Either add the prefix 'r' to your string literals, which prevents the interpretation of this special sequence (for example, path = r"foo\rar" ), or, as already suggested, just use a normal forward slash as a path separator. Python is smart enough to also work on Windows :-)

+14
source

Just use the raw string:

 pd.read_csv(r'C:\Users\rcreedon\Desktop\TEST.csv') 
+6
source

I had a similar problem. You may need to check and see how many tabs are in your excel file. I had a problem when Excel 2010 did not save the entire workbook as a csv file, and I had to save each tab individually. After that I was able to open using Pandas. I would suggest using r ": C \ pathname ...".

0
source

Source: https://habr.com/ru/post/949488/


All Articles