Mar-19-2020, 09:14 PM
Hi there!
I am doing a (beginner) python course online that allows us to use python in a jupyter notebook. I am trying to open a file that looks like a link and is a .csv.
And I get this error:
However I get this error:
I am doing a (beginner) python course online that allows us to use python in a jupyter notebook. I am trying to open a file that looks like a link and is a .csv.
1 2 3 4 5 6 7 8 9 |
links = { 'GDP' : 'https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/PY0101EN/projects/coursera_project/clean_gdp.csv' ,\ 'unemployment' : 'https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/PY0101EN/projects/coursera_project/clean_unemployment.csv' } #GDP = links["GDP"] #print(GDP) with open ( 'https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/PY0101EN/projects/coursera_project/clean_gdp.csv' , 'r' ) as GDPFile: GDPData = GDPFile.read() print (GDPData) print (GDPFile.closed) print (GDPData) |
Error:FileNotFoundError Traceback (most recent call last)
<ipython-input-14-53937e55fa2e> in <module>
4 #GDP = links["GDP"]
5 #print(GDP)
----> 6 with open('https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/PY0101EN/projects/coursera_project/clean_gdp.csv', 'r') as GDPFile:
7 GDPData = GDPFile.read()
8 print(GDPData)
FileNotFoundError: [Errno 2] No such file or directory: 'https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/PY0101EN/projects/coursera_project/clean_gdp.csv'
So I downloaded the file to my local drive and tried it this way: 1 2 3 4 5 6 7 8 9 |
links = { 'GDP' : 'https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/PY0101EN/projects/coursera_project/clean_gdp.csv' ,\ 'unemployment' : 'https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/PY0101EN/projects/coursera_project/clean_unemployment.csv' } #GDP = links["GDP"] #print(GDP) with open ( 'C:\Users\Amanda\Documents\Coursera IBM Data Science Certification\Python for Data Science and AI\clean_gdp.csv' , 'r' ) as GDPFile: GDPData = GDPFile.read() print (GDPData) print (GDPFile.closed) print (GDPData) |
Error:File "<ipython-input-11-59f1f16be3ed>", line 6
with open('C:\Users\Amanda\Documents\Coursera IBM Data Science Certification\Python for Data Science and AI\clean_gdp.csv', 'r') as GDPFile:
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
Am I missing something? Does the file need to be saved in the notebook or under the same project? I'm using python on a data platform, IBM cloud.