Oct-22-2019, 08:00 AM
(Oct-21-2019, 06:12 PM)snippsat Wrote:I have saved the file in C:\Program Files and entered the following code below.Still getting error.(Oct-21-2019, 04:41 PM)tahir1990 Wrote: You mean in the folder where i installed python ?No,where you have placedusstates.csv
.
Example.
with open("usstates.csv", "r") as f: print(f.read())C:\code λ python my_file.py Traceback (most recent call last): File "my_file.py", line 1, in <module> with open("usstates.csv", "r") as f: FileNotFoundError: [Errno 2] No such file or directory: 'usstates.csv'Now i try to openusstates.csv
,but it's not in C:\code folder,if it where in this folder no error.
If i give correct path to placement no error.
with open(r"C:\foo\usstates.csv", "r") as f: print(f.read())C:\code λ python my_file.py hello
with open(r"C:\programfiles\usstates.csv","r") as myfile: print(myfile.read()) Traceback (most recent call last): File "<pyshell#7>", line 1, in <module> with open(r"C:\programfiles\usstates.csv","r") as myfile: FileNotFoundError: [Errno 2] No such file or directory: 'C:\\programfiles\\usstates.csv'