Getting Google Spreadsheet CSV into A Pandas Dataframe

后端 未结 6 673
死守一世寂寞
死守一世寂寞 2020-12-04 09:31

I uploaded a file to Google spreadsheets (to make a publically accessible example IPython Notebook, with data) I was using the file in it\'s native form could be read into a

6条回答
  •  情歌与酒
    2020-12-04 10:18

    Seems to work for me without the StringIO:

    test = pd.read_csv('https://docs.google.com/spreadsheets/d/' + 
                       '0Ak1ecr7i0wotdGJmTURJRnZLYlV3M2daNTRubTdwTXc' +
                       '/export?gid=0&format=csv',
                       # Set first column as rownames in data frame
                       index_col=0,
                       # Parse column values to datetime
                       parse_dates=['Quradate']
                      )
    test.head(5)  # Same result as @TomAugspurger
    

    BTW, including the ?gid= enables importing different sheets, find the gid in the URL.

提交回复
热议问题