Skip to content

Commit 42721ba

Browse files
committed
minor code improvements
1 parent 7573b34 commit 42721ba

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

csv_exporter.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from PyQt5 import QtWidgets
1+
from PyQt5.QtWidgets import QFileDialog
22
from PyQt5 import QtCore
33
from PyQt5 import QtSql
44

@@ -8,18 +8,20 @@
88
class CSV:
99
@staticmethod
1010
def write_csv(model: QtSql.QSqlQueryModel):
11-
filename, _ = QtWidgets.QFileDialog.getSaveFileName(None, "Export data to CSV",
12-
".",
13-
CSV_FILE_FILTER, CSV_FILE_FILTER)
11+
filename, _ = QFileDialog \
12+
.getSaveFileName(None, "Export data to CSV",
13+
".",
14+
CSV_FILE_FILTER, CSV_FILE_FILTER)
1415
data = list()
1516
with open(filename, "a") as f:
17+
# process headers
1618
for i in range(0, model.columnCount()):
1719
header = str(model.headerData(i, QtCore.Qt.Horizontal, QtCore.Qt.DisplayRole))
1820
data.append('"' + header + '"')
19-
21+
# write headers
2022
f.write(";".join(data))
2123
f.write("\n")
22-
24+
# process rows
2325
for i in range(model.rowCount()):
2426
data.clear()
2527
for j in range(model.columnCount()):

0 commit comments

Comments
 (0)