Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
585372bf
Commit
585372bf
authored
Apr 14, 2015
by
panos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Example JSONOutput object modified
parent
8289c722
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
38 deletions
+48
-38
dream/KnowledgeExtraction/KEtool_examples/AssemblyLine/JSONOutput.py
...edgeExtraction/KEtool_examples/AssemblyLine/JSONOutput.py
+48
-38
No files found.
dream/KnowledgeExtraction/KEtool_examples/AssemblyLine/JSONOutput.py
View file @
585372bf
...
...
@@ -23,13 +23,23 @@ Created on 9 Oct 2014
# ===========================================================================
import
json
#Create a method that receives the three dictionaries from the KE tool main script, updates the JSON schema and returns it to the KE tool main script
def
JSON_example
(
list1
,
list2
,
list3
):
#Create an object that receives the three dictionaries from the KE tool main script, updates the JSON schema and returns it to the KE tool main script
class
JSONOutput
(
object
):
def
Distributions
(
self
,
data
):
data1
=
{}
dist
=
data
[
'distributionType'
]
del
data
[
'distributionType'
]
data1
[
dist
]
=
data
data
=
data1
return
data
def
JSONOutput
(
self
,
list1
,
list2
,
list3
):
jsonFile
=
open
(
'JSON_example.json'
,
'r'
)
#open the JSON_example.json file
data
=
json
.
load
(
jsonFile
)
jsonFile
.
close
()
nodes
=
data
.
get
(
'nodes'
,{})
nodes
=
data
[
'graph'
][
'node'
]
batchWIP
=
{}
for
(
element_id
,
element
)
in
nodes
.
iteritems
():
name
=
element
.
get
(
'name'
)
...
...
@@ -51,11 +61,11 @@ def JSON_example(list1,list2,list3):
else
:
continue
if
name
in
list1
.
keys
():
# condition that checks if the element in the list1 is the same as the name of the element in JSON file
element
[
'processingTime'
]
=
list1
[
name
]
# input the attributes of list1[name] to the JSON's element 'processingTime'
element
[
'processingTime'
]
=
self
.
Distributions
(
list1
[
name
])
# input the attributes of list1[name] to the JSON's element 'processingTime'
else
:
continue
if
name
in
list2
.
keys
():
# condition that checks if the element in the list2 is the same as the name of the element in JSON file
element
[
'scrapQuantity'
]
=
list2
[
name
]
# input the attributes of list2[name] to the JSON's element 'scrapQuantity'
if
name
in
list2
.
keys
():
# condition that checks if the element in the list2 is the same as the name of the element in JSON file
element
[
'scrapQuantity'
]
=
self
.
Distributions
(
list2
[
name
])
# input the attributes of list2[name] to the JSON's element 'scrapQuantity'
else
:
continue
jsonFile
=
open
(
'JSON_exampleOutput.json'
,
"w"
)
...
...
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