This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
res ="http://opendata.cwb.gov.tw/opendataapi?dataid=F-D0047-093&authorizationkey=CWB-9C0DCD15-928D-4E3F-A51A-2107C32DB59D" | |
urllib.request.urlretrieve(res,"F-D0047-093.zip") | |
f = zipfile.ZipFile('F-D0047-093.zip') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zipfile | |
import urllib.request | |
import pandas as pd | |
import numpy as np | |
from bs4 import BeautifulSoup | |
import datetime | |
import os | |
import sqlite3 as lite | |
import requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
today = str(datetime.date.today()) | |
cwb_data = "cwb_weather_data" | |
if not os.path.exists(cwb_data): | |
os.mkdir(cwb_data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#開啟壓縮檔,不解壓縮 | |
f = zipfile.ZipFile('F-D0047-093.zip') | |
file = ['63_72hr_CH.xml','64_72hr_CH.xml','65_72hr_CH.xml','66_72hr_CH.xml','67_72hr_CH.xml','68_72hr_CH.xml', | |
'09007_72hr_CH.xml','09020_72hr_CH.xml','10002_72hr_CH.xml','10004_72hr_CH.xml','10005_72hr_CH.xml', | |
'10007_72hr_CH.xml','10008_72hr_CH.xml','10009_72hr_CH.xml','10010_72hr_CH.xml','10013_72hr_CH.xml', | |
'10014_72hr_CH.xml','10015_72hr_CH.xml','10016_72hr_CH.xml','10017_72hr_CH.xml','10018_72hr_CH.xml', | |
'10020_72hr_CH.xml'] | |
CITY = [] | |
DISTRICT = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#轉成Dataframe格式 | |
df = pd.concat([pd.DataFrame({"CITY":CITY}),pd.DataFrame({"DISTRICT":DISTRICT}),pd.DataFrame({"GEOCODE":GEOCODE}), | |
pd.DataFrame({"DAY" : DAY}),pd.DataFrame({"TIME" : TIME}),pd.DataFrame({"TEMP":TEMP}), | |
pd.DataFrame({"TD" : TD}),pd.DataFrame({"RH":RH}),pd.DataFrame({"WIND" : WIND}),pd.DataFrame({"WS" : WS}), | |
pd.DataFrame({"BF":BF}),pd.DataFrame({"AT" : AT}),pd.DataFrame({"Wx": Wx}),pd.DataFrame({"Wx_n":Wx_n}), | |
pd.DataFrame({"PoP6h" : PoP6h}),pd.DataFrame({"PoP12h" :PoP12h}),pd.DataFrame({"get_day":get_day})],axis=1) | |
#存成csv | |
file_path = os.getcwd() | |
save_name = "taiwan_cwb" + today + ".csv" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#轉成list | |
listdata = df.values.tolist() | |
#連結資料庫 | |
conn = lite.connect("weatherapi.sqlite") | |
cur = conn.cursor() | |
cur.execute('create table if not exists weather(CITY text,DISTRICT text,GEOCODE integer,DAY timestamp,TIME timestamp,TEMP integer,TD integer,RH integer,WIND text,WS integer,BF text,AT integer,Wx text,Wx_n integer,PoP6h integer,PoP12h integer,get_day timestamp);') | |
sql = "insert into weather(CITY ,DISTRICT ,GEOCODE ,DAY ,TIME ,TEMP ,TD ,RH,WIND ,WS ,BF ,AT ,Wx ,Wx_n ,PoP6h ,PoP12h ,get_day) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Read more about setting it up | |
# https://medium.com/@ljmocic/deploying-react-application-to-aws-s3-using-github-actions-85addacaeace | |
on: | |
push: | |
tags: | |
- '*' | |
jobs: | |
build: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"semi": false, | |
"tabWidth": 2, | |
"singleQuote": true, | |
"printWidth": 80, | |
"trailingComma": "none", | |
"overrides": [ | |
{ | |
"files": ["*.json5"], | |
"options": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person { | |
name = 'Kurt' | |
getName() { | |
return this.name | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person { | |
constructor() { | |
this.name = 'Kurt' | |
} | |
getName() { | |
return this.name | |
} | |
} |
OlderNewer