I am learning to use the Path tool to import .CSV files in python. I have saved a .CSV file in the same location as the .PY file. here is my code:
from pathlib import Path
csvpath = Path(data_test.csv)
print (csvpath)
The error message is saying: "NameError: name "data_test" is not defined"
what is going on here? the .CSV and .PY files are in the same location. ??
CodePudding user response:
the path should be a string csvpath = Path('data_test.csv')
print (csvpath)
It cant find it, because its looking for a declared variable data_test.csv
CodePudding user response:
from pathlib import Path
csvpath = Path("data_test.csv") # filename should be inside " "
print (csvpath)