Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F1497302
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/natural_values_20200504_1444_1/"
inputFile
=
"out.csv"
inputTags
=
"tag.csv"
outputFileName
=
"out_excel.csv"
headerName
=
"Tag"
classificationOK
=
[
"TRAIN_STABLE"
,
"OPERATION"
]
setOK
=
"1"
classificationDrift
=
[
"TRAIN_DRIFT_UP"
,
"TRAIN_DRIFT_DOWN"
]
setDrift
=
"2"
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
classificationDrift
:
file_content
[
i
]
=
file_content
[
i
][:
-
1
]
+
setDrift
+
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:31 PM (1 d, 4 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
287507
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