I have a CSV file on my F: drive on a 64-bit version of Windows 7 that I would like to read in pandas and manipulate.
None of the examples that I see read anything except a simple file name (for example, "foo.csv").
When I try to do this, I get error messages that do not make the problem clear to me:
import pandas as pd trainFile = "F:/Projects/Python/coursera/intro-to-data-science/kaggle/data/train.csv" trainData = pd.read_csv(trainFile)
The error message says:
IOError: Initializing from file failed
Something is missing for me here. Can anyone see this?
Update:
I got additional information:
import csv if __name__ == '__main__': trainPath = 'F:/Projects/Python/coursera/intro-to-data-science/kaggle/data/train.csv' trainData = [] with open(trainPath, 'r') as trainCsv: trainReader = csv.reader(trainCsv, delimiter=',', quotechar='"') for row in trainReader: trainData.append(row) print trainData
I received a permission error while reading. When I checked the properties of the file, I saw that it was read-only. I was able to read 892 lines successfully after unchecking.
Now pandas works. No need to move the file or change the path. Thanks for watching.
source share