質問編集履歴
1
既存コードの記載
title
CHANGED
File without changes
|
body
CHANGED
@@ -37,6 +37,40 @@
|
|
37
37
|
|
38
38
|
*商品の売上データの商品IDと商品マスターデータの商品IDを紐付け、紐付く商品名と商品価格を出力させます。
|
39
39
|
|
40
|
+
### 既存のプログラム
|
41
|
+
```py
|
42
|
+
import os
|
43
|
+
|
44
|
+
def main():
|
45
|
+
with open('output/sales.csv', mode='w', encoding='utf-8') as sales_f:
|
46
|
+
for name in os.listdir('input/'):
|
47
|
+
if name.startswith('sales_raw_') and name.endswith('.csv') \
|
48
|
+
and "201611" in name:
|
49
|
+
with open(os.path.join('input/', name), encoding='utf-8') as f:
|
50
|
+
for row in f:
|
51
|
+
data = row.rstrip().split(',')
|
52
|
+
|
53
|
+
with open('input/items.csv', encoding='utf-8') as items_f:
|
54
|
+
for row in items_f:
|
55
|
+
data2 = row.rstrip().split(',')
|
56
|
+
if data2[0] == data[2]:
|
57
|
+
sales_f.write(
|
58
|
+
','.join((
|
59
|
+
data[0],
|
60
|
+
data[1],
|
61
|
+
data[2],
|
62
|
+
data2[1],
|
63
|
+
data2[2],
|
64
|
+
data[3],
|
65
|
+
data[4],
|
66
|
+
)) + '\n'
|
67
|
+
)
|
68
|
+
|
69
|
+
|
70
|
+
if __name__ == "__main__":
|
71
|
+
main()
|
72
|
+
```
|
73
|
+
|
40
74
|
### 改修途中のプログラム
|
41
75
|
```py
|
42
76
|
import os
|