Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SMART
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UNI-KLU
SMART
Commits
98fc8f0f
Commit
98fc8f0f
authored
Jan 14, 2021
by
Alexander Lercher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[SemanticLinking] Storing flattened smart-energy transactions as json
parent
aade29cb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
3 deletions
+30
-3
dummy_upload.py
...icroservice/app/dummy_upload/smart_energy/dummy_upload.py
+30
-3
No files found.
src/data-hub/semantic-linking-microservice/app/dummy_upload/smart_energy/dummy_upload.py
View file @
98fc8f0f
...
...
@@ -9,12 +9,14 @@ for modules_path in modules_paths:
sys
.
path
.
insert
(
1
,
modules_path
)
from
messaging.MessageHandler
import
MessageHandler
from
db.repository
import
Repository
# file to read the data from
CSV_FILE
=
r'Energy_Dataset.csv'
handler
=
MessageHandler
()
CSV_FILE
=
r'
dummy_upload\smart_energy\
Energy_Dataset.csv'
handler
=
MessageHandler
(
Repository
()
)
processed_transactions
=
[]
def
upload_transaction
(
transaction
):
'''{"type": "new-trace",
"content": {"use_case": "smart-energy", "table": "smart-energy", "id": "dd2c5146c919b046d77a32a5cf553d5133163562f7b7e1298c878c575d516025",
...
...
@@ -28,7 +30,31 @@ def upload_transaction(transaction):
'id'
:
uid
,
'properties'
:
transaction
,
}
handler
.
handle_new_trace
(
t
)
# handler.handle_new_trace(t)
processed_transactions
.
append
(
t
)
def
store_transactions_for_mirsat
():
'''
Stores the processed transactions as if they would be returned
by Trace Retrieval microservice after fixing the message queue bug.
'''
flattened_transactions
=
[]
for
transaction
in
processed_transactions
:
transaction
=
transaction
[
'properties'
]
transaction
[
'use_case'
]
=
transaction
[
'ApplicationType'
]
del
transaction
[
'ApplicationType'
]
transaction
[
'table'
]
=
transaction
[
'docType'
]
del
transaction
[
'docType'
]
flattened_transactions
.
append
(
transaction
)
import
json
with
open
(
'flattened_smart_energy_data.json'
,
'w'
)
as
file
:
file
.
write
(
json
.
dumps
(
flattened_transactions
))
if
__name__
==
'__main__'
:
...
...
@@ -56,3 +82,4 @@ if __name__ == '__main__':
upload_transaction
(
transaction
)
store_transactions_for_mirsat
()
\ No newline at end of file
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