Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 import CSV (how can i convert my data to csv?)
from pprint import pprint
from urllib.request import urlopen
import json
import csv

city = input('City name: ')

url = '{}&appid=9fd4a33e0db32b96a20241175b963165&units=metric'.format(city)

request = urlopen(url)
text ='utf-8')
data = json.loads(text)


cityy = data['name']
counttry = data['sys']['country']
weatherr = data['weather'][0]['description']
temperaturee = data['main']['temp']
wind_speeeed = data['wind']['speed']

print('City: ', cityy)
print('Country: ', counttry)

for weather in data['weather']:
    desc = weather['main']
    print("Short Description: ", desc)

print('Accurate Description: ', weatherr)
print('Temperature: {} °C'.format(temperaturee))
print('Wind speed: {} m/s'.format(wind_speeeed))

#maybe this help
#with open('podaci.csv', 'w') as csvFile:
    #writer = csv.writer(csvFile)
HI. Need urgent help!

You input name of any city in the world and it prints weather, temperature, wind etc for that city,

and i want those values to be converted into csv...
buran wrote Feb-08-2019, 08:01 AM:
Threads merged and code removed from this post
What is your question? You are using the csv module, although you commented that part out. Is it not working? How exactly is it not working?
Craig "Ichabod" O'Brien -
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures


Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Changing "import numpy as np" to "from numpy import" ClintWestwood 4 980 Nov-28-2018, 06:45 AM
Last Post: nilamo
  Import a Data from a text file maxcom 1 758 Apr-01-2018, 07:30 PM
Last Post: Larz60+

Forum Jump:

Users browsing this thread: 1 Guest(s)