Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
COVID-19-Data-Integration
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ivy Wang
COVID-19-Data-Integration
Commits
9a9b116c
Commit
9a9b116c
authored
3 years ago
by
Arshana Jain
Browse files
Options
Downloads
Patches
Plain Diff
added ukraine daily
parent
2204968a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
daily_data_scripts/daily_europe.py
+46
-25
46 additions, 25 deletions
daily_data_scripts/daily_europe.py
initial_data_scripts/init_europe.py
+0
-11
0 additions, 11 deletions
initial_data_scripts/init_europe.py
with
46 additions
and
36 deletions
daily_data_scripts/daily_europe.py
+
46
−
25
View file @
9a9b116c
import
pandas
as
pd
import
datetime
import
sys
import
sqlite3
# Use this for European countries only. Other countries appear to be either unreliable or have a lot of holes in their data.
def
init_jrc
():
df
=
pd
.
read_csv
(
'
https://raw.githubusercontent.com/ec-jrc/COVID-19/master/data-by-region/jrc-covid-19-regions-latest.csv
'
,
error_bad_lines
=
False
)
# JRC includes Germany data, but not the same subsets
def
init_germany
():
pass
sys
.
path
.
append
(
"
..
"
)
# JRC includes UK data, but not the same subsets
def
init_uk
():
pass
from
util
import
*
# JRC includes Italy data, but not the same subsets
def
init
_italy
():
def
daily
_italy
():
df_total
=
pd
.
read_csv
(
'
https://raw.githubusercontent.com/RamiKrispin/covid19Italy/master/csv/italy_total.csv
'
,
error_bad_lines
=
False
)
df_region
=
pd
.
read_csv
(
'
https://raw.githubusercontent.com/RamiKrispin/covid19Italy/master/csv/italy_region.csv
'
,
error_bad_lines
=
False
)
df_subregion
=
pd
.
read_csv
(
'
https://raw.githubusercontent.com/RamiKrispin/covid19Italy/master/csv/italy_province.csv
'
,
error_bad_lines
=
False
)
# Updates daily. Check for both yesterday's and today's data to make sure they are both gotten regardless of when the source is updated
def
init_ukraine
():
# Updates daily. Check for both the last two days' and today's data to make sure they are all gotten regardless of when the source is updated
def
daily_ukraine
():
conn
=
sqlite3
.
connect
(
'
prototype_db
'
)
c
=
conn
.
cursor
()
# get country_code for Ukraine
ukraine_code
=
get_country_code
(
"
Ukraine
"
,
c
)
# get source id for Ukraine source
ukraine_src_url
=
"
https://github.com/dmytro-derkach/covid-19-ukraine
"
ukraine_src
=
get_source_id
(
ukraine_src_url
,
c
)
dt
=
datetime
.
datetime
.
today
()
csv_name_today
=
'
https://raw.githubusercontent.com/dmytro-derkach/covid-19-ukraine/master/daily_reports/
'
+
(
'
0
'
if
dt
.
month
<
10
else
''
)
+
str
(
dt
.
month
)
+
'
-
'
+
(
'
0
'
if
dt
.
day
<
10
else
''
)
+
str
(
dt
.
day
)
+
'
-
'
+
str
(
dt
.
year
)
+
'
.csv
'
dt
-=
datetime
.
timedelta
(
days
=
1
)
csv_name_yesterday
=
'
https://raw.githubusercontent.com/dmytro-derkach/covid-19-ukraine/master/daily_reports/
'
+
(
'
0
'
if
dt
.
month
<
10
else
''
)
+
str
(
dt
.
month
)
+
'
-
'
+
(
'
0
'
if
dt
.
day
<
10
else
''
)
+
str
(
dt
.
day
)
+
'
-
'
+
str
(
dt
.
year
)
+
'
.csv
'
try
:
df_yesterday
=
pd
.
read_csv
(
csv_name_yesterday
,
error_bad_lines
=
False
)
except
:
pass
ukraine_helper
(
get_date
(
dt
),
ukraine_code
,
ukraine_src
,
c
,
conn
)
for
i
in
range
(
0
,
2
):
dt
-=
datetime
.
timedelta
(
days
=
1
)
ukraine_helper
(
get_date
(
dt
),
ukraine_code
,
ukraine_src
,
c
,
conn
)
def
get_date
(
dt
):
return
(
'
0
'
if
dt
.
month
<
10
else
''
)
+
str
(
dt
.
month
)
+
'
-
'
+
(
'
0
'
if
dt
.
day
<
10
else
''
)
+
str
(
dt
.
day
)
+
'
-
'
+
str
(
dt
.
year
)
def
ukraine_helper
(
date
,
ukraine_code
,
ukraine_src
,
c
,
conn
):
try
:
df_today
=
pd
.
read_csv
(
csv_name_today
,
error_bad_lines
=
False
)
sql
=
'''
SELECT date_collected FROM Cases_Per_Region WHERE date_collected = ?
'''
c
.
execute
(
sql
,
(
date
,
ukraine_src
))
already_entered
=
True
if
c
.
fetchall
()
!=
[]
else
False
if
not
already_entered
:
csv_name
=
'
https://raw.githubusercontent.com/dmytro-derkach/covid-19-ukraine/master/daily_reports/
'
+
date
+
'
.csv
'
df
=
pd
.
read_csv
(
csv_name
,
error_bad_lines
=
False
)
for
row
in
df
.
itertuples
():
region_code
=
get_region_code
(
ukraine_code
,
row
.
Province_State
,
c
)
if
region_code
is
None
:
sql
=
'''
INSERT INTO Regions (region_name, country_code, longitude, latitude) VALUES (?, ?, ?, ?)
'''
c
.
execute
(
sql
,(
row
.
Province_State
,
ukraine_code
,
row
.
Long_
,
row
.
Lat
))
conn
.
commit
()
region_code
=
get_region_code
(
ukraine_code
,
row
.
Province_State
,
c
)
sql
=
'''
INSERT INTO Cases_Per_Region (region_code, date_collected, source_id, death_numbers, case_numbers, recovery_numbers) VALUES (?, ?, ?, ?, ?, ?)
'''
c
.
execute
(
sql
,(
region_code
,
date
,
ukraine_src
,
row
.
Deaths_delta
,
row
.
Confirmed_delta
,
row
.
Recovered_delta
))
conn
.
commit
()
except
:
pass
def
init_france
():
pass
pass
\ No newline at end of file
This diff is collapsed.
Click to expand it.
initial_data_scripts/init_europe.py
+
0
−
11
View file @
9a9b116c
...
...
@@ -11,14 +11,6 @@ from util import *
def
init_jrc
():
df
=
pd
.
read_csv
(
'
https://raw.githubusercontent.com/ec-jrc/COVID-19/master/data-by-region/jrc-covid-19-all-days-by-regions.csv
'
,
error_bad_lines
=
False
)
# JRC includes Germany data, but not the same subsets
def
init_germany
():
pass
# JRC includes UK data, but not the same subsets
def
init_uk
():
pass
# JRC includes Italy data, but not the same subsets
def
init_italy
():
df_total
=
pd
.
read_csv
(
'
https://raw.githubusercontent.com/RamiKrispin/covid19Italy/master/csv/italy_total.csv
'
,
error_bad_lines
=
False
)
...
...
@@ -132,6 +124,3 @@ def init_ukraine():
dt
+=
datetime
.
timedelta
(
days
=
1
)
conn
.
close
()
def
init_france
():
pass
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment