简体   繁体   中英

Any way to create an excel sheet with data from a url with python

Sorry if the title is confusing. Basically what I am trying to do is create an excel sheet with data that is in a url that I have.

The url is a search API for twitter that retrieves the past 100 tweets with a given keyword of my choice. I am trying to to create an excel sheet that stores each tweet in it's own row. Essentially it will only be 1 column but will be 100 rows.

I have looked online but haven't really seen a way to do exactly what I need so if anyone knows a tutorial i should look at or could show me how to get started that would be great.

Thanks!

There will probably not be a tutorial on exactly how to do this. you need to put a couple different concepts together

  1. Get the data from the url. This can be as simple as urllib.urlopen
  2. Turn that data (string) into a usable format. Twitter will probably return json. Turn that into a python dict
  3. Open a file for writing
  4. Loop through twitter data and write to ouput file

You only need to create a .csv file. It will work great with excel. For one column file you just need to write the header then write each line of data. Python provides everything you need to create well formed csv files in the csv module in the standard library

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