回答編集履歴
1
コードをテキストで貼ったのを修正しました。
test
CHANGED
@@ -1,21 +1,31 @@
|
|
1
|
+
```ここに言語を入力
|
2
|
+
|
3
|
+
import csv
|
4
|
+
|
5
|
+
import sqlite3
|
6
|
+
|
7
|
+
|
8
|
+
|
1
9
|
conn = sqlite3.connect('./temp/test.db')
|
2
10
|
|
3
11
|
c = conn.cursor()
|
4
12
|
|
5
13
|
|
6
14
|
|
7
|
-
with open ('./temp/rawdata_sorted
|
15
|
+
with open ('./temp/rawdata_sorted.csv',"w",newline='', encoding="utf-8") as f_handle:
|
8
16
|
|
9
|
-
|
17
|
+
writer = csv.writer(f_handle)
|
10
18
|
|
11
|
-
|
19
|
+
header = [ 'KB','VIN_NUM','MODEL_CD','DATA_YMD','M2M_REPORT_ID','M2M_REPORT_ID_SUB','M2M_REPORT_ROW_ID','M2M_REPORT_COL_ID','CALC_VAL']
|
12
20
|
|
13
|
-
|
21
|
+
writer.writerow(header)
|
14
22
|
|
15
|
-
|
23
|
+
for row in c.execute('SELECT * FROM hoge ORDER BY VIN_NUM ASC,MODEL_CD ASC,DATA_YMD ASC,M2M_REPORT_ID ASC,M2M_REPORT_ID_SUB ASC,M2M_REPORT_ROW_ID ASC,M2M_REPORT_COL_ID ASC,M2M_REPORT_COL_ID ASC,CALC_VAL ASC'):
|
16
24
|
|
17
|
-
|
25
|
+
writer.writerow(row)
|
18
26
|
|
19
|
-
|
27
|
+
|
20
28
|
|
21
29
|
conn.close()
|
30
|
+
|
31
|
+
```
|