Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Ethan Mertz
/
CS-123-Final
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Pipelines
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
12efb152
authored
Jun 01, 2018
by
Anselm Jia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
to json
parent
8d16ddb7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
Python/text_to_dict.py
Python/text_to_dict.py
0 → 100644
View file @
12efb152
import
json
def
to_json
(
filename
,
dataname
):
resultdict
=
{}
with
open
(
filename
)
as
resultfile
:
results
=
resultfile
.
readlines
()
for
result
in
results
:
name
,
score
=
result
.
split
(
"
\t
"
)
name
=
name
.
replace
(
'"'
,
''
)
score
=
score
.
strip
()
resultdict
[
name
]
=
float
(
score
)
with
open
(
dataname
,
'w'
)
as
datafile
:
json
.
dump
(
resultdict
,
datafile
)
\ 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