It is possible to read csv into Google Colab by several ways. For reading csv from online folder basic read w/o permission is enough, but for usage of Google Drive File System, authorisation is needed. E.g.
basic csv read - use pandas, os, csv, etc.
read csv from Google Drive with Mount Authorisation
1.
# use pandas
import pandas as pd
# use os to work with mac file system
import os
os.getcwd()
os.chdir('/datalab')
# get current work directory by pwd
pwd
'/content'
# get current work directory by pwd
df = pd.read_csv('survey_results_public.csv')
schema_df = pd.read_csv('survey_results_schema.csv')
2.
# Upload csv to google colab and read csv
from google.colab import drive drive.mount('/content/gdrive')
# Click the generated link and go to the URL below
Enter your authorization code: xxxxxxxxxxxxxxxxxxx
Mounted at /content/gdrive
# or get current work directory by os
import os
os.getcwd()
os.listdir()
'/content'
['.config',
'survey_results_public.csv',
'gdrive',
'survey_results_schema.csv',
'sample_data']
# Read dataset to data frame
from google.colab import drive
import pandas as pd df=pd.read_csv('gdrive/MyDrive/Dataset_for_Colab/fake_job_postings.csv') df
# Training csv file has been found here: https://www.kaggle.com/shivamb/real-or-fake-fake-jobposting-prediction?select=fake_job_postings.csv
Comments