Read a csv file from Google cloud storage

Hello Team,

I am new o Streamlit. I am trying to read a csv file from my google cloud storage (https://storage.cloud.google.com/timeseriesdata/devicedetails.csv). I have implemented the below code, but I am getting the tokenization error.

DATA_URL = (
    "https://storage.cloud.google.com/timeseriesdata/devicedetails.csv"
)

@st.cache(persist=True)

def load_data(nrows):

    data = pd.read_csv(DATA_URL, nrows=nrows)
    return data
   
data = load_data(10)

I would like to see the results in the form of a table. I have enclosed my error message as an attachment. Kindly suggest me on this.

Thanks and Regards,
S.Thilak

Hi @Thilak -

This is a pandas error, not a Streamlit one specifically. Since you don’t specify the exact columns and types on the read_csv statement, pandas infers this for you. However, in your file, it’s indicating that it thought you had a file with one column, but then in a different row, the number of commas indicates there are two columns. So pandas throws an error so you can indicate which one is correct.

This type of error can happen with files with no header, data elements with embedded commas, and lots of other ways. How to solve it depends on what data is actually in your file.

Best,
Randy

1 Like

Hey @randyzwitch

Thanks for the information, I have checked the input file, looks like it requires data types to be mentioned for each column. I could able to figure it out.

Thanks and Regards,
S.Thilak

1 Like