Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Temperaturverteilung
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
s39174
Temperaturverteilung
Commits
3896f2f1
Commit
3896f2f1
authored
3 years ago
by
Peter Morstein
Browse files
Options
Downloads
Patches
Plain Diff
parse dataframe id to extra station_id column
parent
d4c12775
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
dataacquisition/ExportToDatabase.py
+4
-1
4 additions, 1 deletion
dataacquisition/ExportToDatabase.py
dataacquisition/test_ExportToDatabase.py
+1
-0
1 addition, 0 deletions
dataacquisition/test_ExportToDatabase.py
with
5 additions
and
1 deletion
dataacquisition/ExportToDatabase.py
+
4
−
1
View file @
3896f2f1
...
...
@@ -144,6 +144,7 @@ def create_matrix_data(cursor, amount_points):
def
createInsertStatement
(
station_list
):
# create INSERT INTO table (columns) VALUES('%s',...)
station_list
.
columns
.
astype
(
str
)
df_columns
=
list
(
station_list
)
station_list
=
station_list
.
round
(
decimals
=
3
)
values
=
"
VALUES({})
"
.
format
(
"
,
"
.
join
([
"
%s
"
for
_
in
df_columns
]))
...
...
@@ -166,8 +167,10 @@ def insert_data(station_list, cursor):
# for column in df_columns:
# columns.append('"' + column + '"')
#columns = str(columns).replace('[', '').replace(']', '').replace("'", "").replace('\n', '').replace(' ', '')
station_list
[
"
station_id
"
]
=
station_list
.
index
station_list
=
station_list
.
round
(
decimals
=
3
)
# create VALUES('%s', '%s",...) one '%s' per column
#values = "VALUES({})".format(",".join(["%s" for _ in df_columns]))
...
...
This diff is collapsed.
Click to expand it.
dataacquisition/test_ExportToDatabase.py
+
1
−
0
View file @
3896f2f1
...
...
@@ -92,6 +92,7 @@ class TestExportToDatabase(unittest.TestCase):
with
open
(
"
./dataacquisition/pickle/stationList_with_temperature.pickle
"
,
"
rb
"
)
as
pickleFile
:
stationList
=
pickle
.
load
(
pickleFile
)
stationList
=
stationList
.
loc
[
stationList
[
'
country
'
]
==
"
Germany
"
]
stationList
[
"
station_id
"
]
=
stationList
.
index
insert_stmt
=
cut
.
createInsertStatement
(
stationList
)
...
...
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