<h3>2 Ways to load CSV files to Google Colab</h3><pre>#ipynb #initial setup import pandas as pd</pre><p><br></p><h4>Option1 : From Github</h4><p>This has a limitation on file size to upload to github, up to 25MB. You need to upload your csv file to github first and copy the remote repository link from github</p><pre>#ipynb #paste github link from github remote repository url = '{your github remote repository https link here}' df1 = pd.read_csv(url) df1.shape #check dataset shape</pre><p>You can use test data set I've used from <a href="https://github.com/Tak113/test_csv_data" target="_blank">here</a><br></p><p><br></p><h4>Option2 : From Local Drive</h4><p>You might need to install dependencies first through `pip`</p><pre>#ipynb at google colab !pip install files</pre><pre>#ipynb #select file from local computer from google.colab import files uploaded = files.upload()</pre><p>This `uploaded` asks you to choose local file. Choose csv file from your local drive (let's say you pick up `xxx.csv`</p><p><br></p><pre>#ipynb #import to dataframe import io df2 = pd.read_csv(io.Bytes(uploaded['xxx.csv'])) df2.shape #check dataset shape</pre><p><br></p><h4>Option3 : From google spreadsheet</h4><p>The requirement keeps changing and it's still under study... will be updated once it's firm for me</p><p><br></p><p>Original source code is at google colab : <a href="https://colab.research.google.com/drive/1OLE71q1T9brvLxnSNfN1lyARfeeLFz4p?usp=sharing" target="_blank" style="background-color: rgb(255, 255, 255);">Google Colab</a></p><p>Ref : <a href="https://towardsdatascience.com/3-ways-to-load-csv-files-into-colab-7c14fcbdcb92" target="_blank">toward data science</a></p>
<< Back to Blog Posts
Back to Home