Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
smogonet
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dominik Rosiek
smogonet
Commits
35e203ec
Commit
35e203ec
authored
Dec 20, 2016
by
Dominik Rosiek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update database from csv files
parent
a5ec0bbd
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
0 deletions
+57
-0
pollutions_csv.py
pollutions_csv.py
+22
-0
stations.csv
stations.csv
+7
-0
stations_csv.py
stations_csv.py
+23
-0
syfy.csv
syfy.csv
+5
-0
No files found.
pollutions_csv.py
0 → 100644
View file @
35e203ec
from
uuid
import
UUID
from
functools
import
partial
import
models
import
csv
from
tornado.gen
import
coroutine
from
tornado.ioloop
import
IOLoop
@
coroutine
def
main
():
with
open
(
"syfy.csv"
,
'r'
)
as
csvfile
:
reader
=
csv
.
reader
(
csvfile
)
next
(
reader
)
for
row
in
reader
:
uuid
=
UUID
(
int
=
int
(
row
[
0
]))
station
=
models
.
Type
(
shortname
=
row
[
1
],
longname
=
row
[
2
],
description
=
row
[
2
],
norm
=
row
[
5
],
unit
=
row
[
4
],
type_id
=
uuid
)
result
=
yield
station
.
save
()
IOLoop
.
current
()
.
run_sync
(
main
)
stations.csv
0 → 100644
View file @
35e203ec
id,name,city,lat,long
1,Al. Krasińskiego,Kraków,50.057678,19.926189
2,ul. Bulwarowa,Kraków,50.069308,20.053492
3,ul. Bujaka,Kraków,50.010575,19.949189
13,ul. Dietla,Kraków,50.057447,19.946008
14,os. Piastów,Kraków,50.099361,20.018317
15,ul. Złoty Róg,Kraków,50.081197,19.895358
stations_csv.py
0 → 100644
View file @
35e203ec
from
uuid
import
UUID
from
functools
import
partial
import
models
import
csv
from
tornado.gen
import
coroutine
from
tornado.ioloop
import
IOLoop
@
coroutine
def
main
():
with
open
(
"stations.csv"
,
'r'
)
as
csvfile
:
reader
=
csv
.
reader
(
csvfile
)
next
(
reader
)
for
row
in
reader
:
print
(
row
)
uuid
=
UUID
(
int
=
int
(
row
[
0
]))
station
=
models
.
Station
(
station_id
=
uuid
,
city
=
row
[
2
],
name
=
row
[
1
],
longitude
=
float
(
row
[
3
])
*
10e6
,
latitude
=
float
(
row
[
4
])
*
10e6
,
api_station_id
=
row
[
0
])
result
=
yield
station
.
save
()
IOLoop
.
current
()
.
run_sync
(
main
)
syfy.csv
0 → 100644
View file @
35e203ec
id,name,description,html,unit,norm
1,pm10,pył PM10,PM 10,µg/m³,50
2,pm2.5,pył PM2.5,PM 2.5,µg/m³,25
3,no2,dwutlenek azotu,NO<sub>2</sub>,µg/m³,40
7,co,tlenek węgla,CO,µg/m³,10000
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment