When I put the code into excel every character is spaced out. This causes Tuesday to look like T,u,e,s,d,a,y in excel. The goal would be to have each cell in excel to have its own word and not the character. There are many for loops and I struggle with finding an answer to this ongoing problem. Any ideas?
import requests
from pprint import pprint
from xml.dom.minidom import parseString
from openpyxl import Workbook
NMNorth2=[("Farmington"),("Gallup"),("Grants"),("Las_Vegas"),("Raton"),("Santa_Fe"), ("Taos"),("Tijeras"),("Tucumcari")]
NMNorth=[("NM", "Farmington"),("NM", "Gallup"),("NM", "Grants"),("NM", "Las_Vegas"),("NM", "Raton"),("NM", "Santa_Fe"), ("NM", "Taos"),("NM", "Tijeras"),("NM", "Tucumcari")]
wb = Workbook()
dest_filename = 'weather.xlsx'
ws1 = wb.active
ws1.title = "Weather"
for state, city in NMNorth:
r = requests.get("http://api.wunderground.com/api/id/forecast/q/"+state+"/"+city+".json")
data = r.json()
forecast = data['forecast']['txt_forecast']['forecastday']
for n in forecast:
day = n['title']
forecaststm = (n['fcttext'])
columnVariable = 2
for x in day:
ws1.cell(row = 1, column = columnVariable).value = x
columnVariable +=1
for y in forecaststm:
ws1.cell(row = 2, column = columnVariable).value = y
columnVariable +=1
rowVariable = 2
ws1.cell(row = 1, column = 1).value = "City"
for state in NMNorth2:
ws1.cell(row = rowVariable, column = 1).value = state
rowVariable +=1
wb.save(filename = dest_filename)