質問編集履歴

1

既存コードの記載

2021/05/13 02:36

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -76,6 +76,74 @@
76
76
 
77
77
 
78
78
 
79
+ ### 既存のプログラム
80
+
81
+ ```py
82
+
83
+ import os
84
+
85
+
86
+
87
+ def main():
88
+
89
+ with open('output/sales.csv', mode='w', encoding='utf-8') as sales_f:
90
+
91
+ for name in os.listdir('input/'):
92
+
93
+ if name.startswith('sales_raw_') and name.endswith('.csv') \
94
+
95
+ and "201611" in name:
96
+
97
+ with open(os.path.join('input/', name), encoding='utf-8') as f:
98
+
99
+ for row in f:
100
+
101
+ data = row.rstrip().split(',')
102
+
103
+
104
+
105
+ with open('input/items.csv', encoding='utf-8') as items_f:
106
+
107
+ for row in items_f:
108
+
109
+ data2 = row.rstrip().split(',')
110
+
111
+ if data2[0] == data[2]:
112
+
113
+ sales_f.write(
114
+
115
+ ','.join((
116
+
117
+ data[0],
118
+
119
+ data[1],
120
+
121
+ data[2],
122
+
123
+ data2[1],
124
+
125
+ data2[2],
126
+
127
+ data[3],
128
+
129
+ data[4],
130
+
131
+ )) + '\n'
132
+
133
+ )
134
+
135
+
136
+
137
+
138
+
139
+ if __name__ == "__main__":
140
+
141
+ main()
142
+
143
+ ```
144
+
145
+
146
+
79
147
  ### 改修途中のプログラム
80
148
 
81
149
  ```py