Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F1497209
csv_to_excelCSV_and_Tags.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Size
1 KB
Referenced Files
None
Subscribers
None
csv_to_excelCSV_and_Tags.py
View Options
#!/usr/bin/env python3
import
csv
import
os
from
os
import
listdir
from
os.path
import
isfile
,
join
inputPath
=
"./splitted_data/values_20200325_1312_1/"
inputFile
=
"out.csv"
inputTags
=
"tag.csv"
outputFileName
=
"out_excel.csv"
headerName
=
"Tag"
classificationOK
=
[
"TRAIN_STABLE"
,
"OPERATION"
]
setOK
=
"1"
classificationDriftDn
=
[
"TRAIN_DRIFT_DOWN"
]
setDriftDn
=
"2"
classificationDriftUp
=
[
"TRAIN_DRIFT_UP"
]
setDriftUp
=
"4"
with
open
(
inputPath
+
"/"
+
inputFile
,
'r'
)
as
file
:
file_content
=
file
.
readlines
()
with
open
(
inputPath
+
"/"
+
inputTags
,
'r'
)
as
t
:
reader
=
csv
.
reader
(
t
)
tags
=
list
(
reader
)
file_content
[
0
]
=
file_content
[
0
][:
-
1
]
+
headerName
+
file_content
[
0
][
-
1
:]
for
i
in
range
(
1
,
len
(
file_content
)):
if
tags
[
i
-
1
][
0
]
in
classificationOK
:
file_content
[
i
]
=
file_content
[
i
][:
-
1
]
+
setOK
+
file_content
[
i
][
-
1
:]
elif
tags
[
i
-
1
][
0
]
in
classificationDriftDn
:
file_content
[
i
]
=
file_content
[
i
][:
-
1
]
+
setDriftDn
+
file_content
[
i
][
-
1
:]
elif
tags
[
i
-
1
][
0
]
in
classificationDriftUp
:
file_content
[
i
]
=
file_content
[
i
][:
-
1
]
+
setDriftUp
+
file_content
[
i
][
-
1
:]
else
:
print
(
tags
[
i
-
1
][
0
],
" is not included! i = "
,
i
)
input
()
file_content
=
[
f
.
replace
(
','
,
';'
)
for
f
in
file_content
]
file_content
=
[
f
.
replace
(
'.'
,
','
)
for
f
in
file_content
]
with
open
(
inputPath
+
"/"
+
outputFileName
,
'w'
)
as
file
:
file
.
writelines
(
file_content
)
File Metadata
Details
Attached
Mime Type
text/x-script.python
Expires
Sun, Mar 1, 9:29 PM (1 d, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
287597
Default Alt Text
csv_to_excelCSV_and_Tags.py (1 KB)
Attached To
Mode
R20 SoC_Rosa_repo
Attached
Detach File
Event Timeline
Log In to Comment