简体   繁体   中英

Read csv to sframe in google colab

I have created a new notebook of python 2 on google-colaboratory and installed sframe(!pip install sframe) but I'm unable to read the CSV file in sframe. Any help?

To read a CSV file in a SFrame, you need to download either turicreate module or GraphLab create module.

Firstly, you need to import data into colab. So you need to recognize how are you accessing your file: local storage or google drive. You can use this link to achieve this: Import data into Google Colaboratory .

For downloading the turicreate module in google-colaboratory, do the following steps:

1) Install turicreate module using pip in colab.

        !pip install turicreate

2) Import the turicreate module.

        import turicreate

3) Use the turicreate.SFrame.read_csv function to import the CSV file into the sframe. Assume that the content of the CSV file is stored as 'file.csv' and the name of the SFrame is 'sf' , use the code below to read the CSV data into a SFrame.

        sf = turicreate.SFrame.read_csv('file.csv')

That's it !!! You can also do the same with Graphlab create.

Refer to the API documentations over here:

https://apple.github.io/turicreate/docs/api/generated/turicreate.SFrame.read_csv.html#turicreate.SFrame.read_csv

https://turi.com/products/create/docs/generated/graphlab.SFrame.read_csv.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM