I am trying to import data form my folder with this code
from google.colab import files
uploaded = files.upload()
for fn in uploaded.keys():
print('User uploaded file "{name}" with length {length} bytes'.format(name=fn, length=len(uploaded[fn])))
but it gives me this error :
Traceback (most recent call last) <ipython-input-7-3ff52e25531b> in <module>()
1 from google.colab import files
2
----> 3 uploaded = files.upload()
4
5 #for fn in uploaded.keys():
/usr/local/lib/python3.6/dist-packages/google/colab/files.py in upload()
70 result = _output.eval_js(
71 'google.colab._files._uploadFilesContinue("{output_id}")'.format(
---> 72 output_id=output_id))
73 if result['action'] != 'append':
74 # JS side uses a generator of promises to process all of the files- some
/usr/local/lib/python3.6/dist-packages/google/colab/output/_js.py in eval_js(script, ignore_result)
37 if ignore_result:
38 return
---> 39 return _message.read_reply_from_input(request_id)
40
41
/usr/local/lib/python3.6/dist-packages/google/colab/_message.py in read_reply_from_input(message_id, timeout_sec)
104 reply.get('colab_msg_id') == message_id):
105 if 'error' in reply:
--> 106 raise MessageError(reply['error'])
107 return reply.get('data', None)
108
MessageError: RangeError: Maximum call stack size exceeded.
which I did not understand. is the reason the data relatively big (22578685bytes) or is it because of javascript?
Click on “Choose Files” then select and upload the file. Wait for the file to be 100% uploaded. You should see the name of the file once Colab has uploaded it. Finally, type in the following code to import it into a dataframe (make sure the filename matches the name of the uploaded file).
Uploading file using Colab files module You can import files module from google. colab . Then call upload() to launch a “File Upload” dialog and select the file(s) you wish to upload. Once the upload is complete, your file(s) should appear in “Files explorer” and you can read the file as you would normally.
Since a Colab notebook is hosted on Google's cloud servers, there's no direct access to files on your local drive (unlike a notebook hosted on your machine) or any other environment by default. However, Colab provides various options to connect to almost any data source you can imagine.
My suggestion is to try uploading the file using the file browser instead. (It uses a distinct transport that's much more efficient, particularly for large files.)
Does that correct the problem?
I was using colab in safari on my mac then it gave me this error. Trien uploading from the button above mentioned but did not work.
Simply ran the colab in Google Chrome and it worked smoothly for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With