Jack.Sparrow
Jack.Sparrow

Reputation: 151

FileNotFoundError File does not exist

import pandas as pd

df = pd.read_csv("E:\YangJian\jupyter notebook\movie_metadata.csv")
train = pd.read_csv("E:\YangJian\jupyter notebook\train_modified.csv")

when i run "df",it's ok,but when i run "train",it's turns out as follows: File b'E:\YangJian\jupyter notebook\train_modified.csv' does not exist

enter image description here

Upvotes: 1

Views: 3604

Answers (1)

DeepSpace
DeepSpace

Reputation: 81604

The second path contains \t that becomes a tab character. It turns the path to 'E:\YangJian\jupyter notebook rain_modified.csv'

The solution is to always use raw strings when dealing with paths. Add r before the string literal:

df = pd.read_csv(r"E:\YangJian\jupyter notebook\movie_metadata.csv")
#                ^
train = pd.read_csv(r"E:\YangJian\jupyter notebook\train_modified.csv")
#                   ^

Upvotes: 2

Related Questions