import urllib
import urllib2
import csv
import pandas
#Calling this function will download a csv and return it in a dataframe
#21 AUG 2018
#David Tsang
def downloadasdataframe(url):
req = urllib2.Request(url)
response = urllib2.urlopen(req)
reader = csv.reader(response)
ls_data = list(reader)
headers = ls_data[0]
df_data = pandas.DataFrame.from_records(ls_data[1:], columns=headers)
return df_data
No comments:
Post a Comment