Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SGS18-READEX
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Ondrej Vysocky
SGS18-READEX
Commits
719994ff
Commit
719994ff
authored
6 years ago
by
Ivo Peterek
Browse files
Options
Downloads
Patches
Plain Diff
ENH: edit csv source values gui added
#6
parent
3e14cf99
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/csv_vals_edit.py
+96
-0
96 additions, 0 deletions
src/csv_vals_edit.py
with
96 additions
and
0 deletions
src/csv_vals_edit.py
0 → 100644
+
96
−
0
View file @
719994ff
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'csv_vals_edit.ui'
#
# Created by: PyQt5 UI code generator 5.10.1
#
# WARNING! All changes made in this file will be lost!
import
os
import
glob
import
csv
from
runpy
import
run_path
from
PyQt5
import
QtCore
,
QtGui
,
QtWidgets
class
Ui_csv_vals_edit
(
object
):
def
setupUi
(
self
,
csv_vals_edit
,
region
,
xLabel
,
xLabelVal
,
funcLabel
,
funcLabelVal
,
yLabel
):
csv_vals_edit
.
setObjectName
(
"
csv_vals_edit
"
)
csv_vals_edit
.
resize
(
350
,
523
)
self
.
centralwidget
=
QtWidgets
.
QWidget
(
csv_vals_edit
)
self
.
centralwidget
.
setObjectName
(
"
centralwidget
"
)
self
.
tableWidget
=
QtWidgets
.
QTableWidget
(
self
.
centralwidget
)
self
.
tableWidget
.
setGeometry
(
QtCore
.
QRect
(
20
,
10
,
310
,
450
))
self
.
tableWidget
.
setRowCount
(
0
)
self
.
tableWidget
.
setColumnCount
(
1
)
self
.
tableWidget
.
setObjectName
(
"
tableWidget
"
)
self
.
tableWidget
.
horizontalHeader
().
setDefaultSectionSize
(
310
)
self
.
tableWidget
.
horizontalHeader
().
setMinimumSectionSize
(
310
)
self
.
tableWidget
.
horizontalHeader
().
setSortIndicatorShown
(
False
)
self
.
tableWidget
.
verticalHeader
().
setVisible
(
False
)
self
.
tableWidget
.
verticalHeader
().
setDefaultSectionSize
(
31
)
self
.
pushButton_save
=
QtWidgets
.
QPushButton
(
self
.
centralwidget
)
self
.
pushButton_save
.
setGeometry
(
QtCore
.
QRect
(
240
,
480
,
89
,
25
))
self
.
pushButton_save
.
setObjectName
(
"
pushButton_save
"
)
csv_vals_edit
.
setCentralWidget
(
self
.
centralwidget
)
self
.
retranslateUi
(
csv_vals_edit
)
QtCore
.
QMetaObject
.
connectSlotsByName
(
csv_vals_edit
)
self
.
tableWidget
.
setHorizontalHeaderLabels
([
yLabel
[
0
]
+
"
"
+
yLabel
[
1
]])
#self.vals = self.get_vals_from_csv(region, xLabel, xLabelVal, funcLabel, funcLabelVal, yLabel)
def
retranslateUi
(
self
,
csv_vals_edit
):
_translate
=
QtCore
.
QCoreApplication
.
translate
csv_vals_edit
.
setWindowTitle
(
_translate
(
"
csv_vals_edit
"
,
"
Source CSV values edit
"
))
self
.
pushButton_save
.
setText
(
_translate
(
"
csv_vals_edit
"
,
"
Save
"
))
def
get_vals_from_csv
(
self
,
region
,
xLabel
,
xLabelVal
,
funcLabel
,
funcLabelVal
,
yLabel
):
# input: yLabel-tuple (category, arg)
config_dic
=
run_path
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)))
\
+
'
/.gui_tmp_config_{}.py
'
.
format
(
os
.
getpid
()))
xLabelInd
=
[
i
for
i
,
x
in
enumerate
(
config_dic
[
'
file_name_args_tup
'
])
if
xLabel
in
x
]
funcLabelInd
=
[
i
for
i
,
x
in
enumerate
(
config_dic
[
'
file_name_args_tup
'
])
if
funcLabel
in
x
]
data_path
=
config_dic
[
'
root_folder
'
][
0
][
0
]
+
"
/
"
+
region
csv_names
=
glob
.
glob
(
data_path
+
'
/*.csv
'
)
first_csv_path
=
csv_names
[
0
]
first_csv_name
=
first_csv_path
.
split
(
'
/
'
)[
-
1
].
rsplit
(
'
.
'
,
1
)[
0
].
split
(
'
_
'
)
target_csv_name
=
first_csv_name
target_csv_name
[
xLabelInd
[
0
]]
=
xLabelVal
target_csv_name
[
funcLabelInd
[
0
]]
=
funcLabelVal
target_csv_name
=
(
'
_
'
).
join
(
target_csv_name
)
+
"
.csv
"
target_csv_path
=
data_path
+
'
/
'
+
target_csv_name
vals_ind
=
[]
vals
=
[]
with
open
(
target_csv_path
)
as
csvfile
:
reader
=
csv
.
reader
(
csvfile
,
delimiter
=
'
,
'
)
yLabel_category
=
False
for
i
,
line
in
enumerate
(
reader
):
if
line
[
0
].
startswith
(
'
#
'
)
and
not
line
[
0
].
startswith
(
"
# CALLTREE
"
):
line_tmp
=
line
[
0
].
split
(
'
#
'
)[
1
].
strip
()
if
line_tmp
==
yLabel
[
0
]:
yLabel_category
=
True
else
:
yLabel_category
=
False
if
line
[
0
]
==
yLabel
[
1
]
and
yLabel_category
:
vals_ind
.
append
(
i
)
csvfile
.
seek
(
0
)
all_vals_lst
=
list
(
enumerate
(
reader
))
for
i
in
vals_ind
:
vals
.
append
(
all_vals_lst
[
i
][
1
])
vals_with_ind
=
zip
(
vals
,
vals_ind
)
return
vals_with_ind
if
__name__
==
"
__main__
"
:
import
sys
app
=
QtWidgets
.
QApplication
(
sys
.
argv
)
csv_vals_edit
=
QtWidgets
.
QMainWindow
()
ui
=
Ui_csv_vals_edit
()
ui
.
setupUi
(
csv_vals_edit
,
'
LTimes
'
,
'
CF
'
,
'
12
'
,
'
UnCF
'
,
'
12
'
,
(
'
Job info - rapl
'
,
'
Runtime of function [s]
'
))
csv_vals_edit
.
show
()
sys
.
exit
(
app
.
exec_
())
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment