I am scraping a table from a website and writing it to a csv file. The name of the file is correct, however I need the name of the sheet within the workbook to be "Raw_Data", rather than the file name. Here is what I have so far:
import urllib.request
import json
import re
import datetime
html = urllib.request.urlopen("https://www.wunderground.com/personal-weather-station/dashboard?ID=KNYSENEC1#history/tdata/s20171104/e20171104/mdaily").read().decode('utf8')
json_data = re.findall(r'pws_bootstrap:(.*?)\s+,\s+country\:', html, re.S)
data = json.loads(json_data[0])
nnow = datetime.datetime.now().date()
Filenamee = "seneca_weather_" + str(nnow)
filename = ('%s.csv' % Filenamee)
f = open(filename, "w")
for days in data['history']['days']:
for obs in days['observations']:
f.write(str(obs['date']['iso8601']) + "," + str(obs['temperature']) + "," + str(obs['pressure']) + "," + str(obs['wind_dir']) + "," + str(obs['wind_speed']) + "," + str(obs['precip_today']) + "\n")
I'm very new to both python and webscraping so sorry for the super broad question. Thanks