Working with CSV on COLAB

Working with CSV on COLAB

Load remote CSV data into a Pandas DataFrame

# load the remote data into a Pandas DataFrame
import pandas as pd
df = pd.read_csv('https://archive.org/download/crowdflower/text_emotion.csv', on_bad_lines='skip', encoding='latin-1')
df

colab example

Upload CSV file via upload object to be read by Pandas DataFrame

# using upload object to upload csv
from google.colab import files
import pandas as pd

uploaded = files.upload()
# assume that the user uploaded only one file
# and the file is a csv format
df = pd.read_csv(io.BytesIO(uploaded[list(uploaded.keys())[0]]))
df

colab example