Pedro Puertas
Pedro Puertas

Reputation: 21

To read csv in google colaboratore


from google.colab import files
uploaded = files.upload()
import io

def ls(ruta = uploaded):
    return [arch.name for arch in io.StringIO((ruta)) if arch.is_file()]
divisas = ls()

I have this error:

TypeError: initial_value must be str or None, not dict

Upvotes: 0

Views: 98

Answers (2)

Sebin Sunny
Sebin Sunny

Reputation: 1803

from google.colab import files
uploaded = files.upload()
Import the google.colab library for file upload then upload the file and pass file name inside the pandas read_csv function

import io
import pandas as pd
df2 = pd.read_csv(io.BytesIO(uploaded['heart.csv']))
df2.head()
enter image description here

Upvotes: 2

Pedro Puertas
Pedro Puertas

Reputation: 21

I need to include the file names in divisas list

Upvotes: 0

Related Questions