回答編集履歴

1

修正

2022/11/02 04:52

投稿

can110
can110

スコア38262

test CHANGED
@@ -1,12 +1,9 @@
1
- 別のcsvファイルとして保存したいのであれば別ファイル名で書込みファイル開く必要があります。
1
+ 込みファイルは各読取~計算ループの外側で開く必要があります。
2
2
  ```Python
3
+ with open('data.csv', 'wt', encoding='utf-8') as fout:
3
- for fn in sys.argv[1:]:
4
+ for fn in sys.argv[1:]:
4
- with open(fn, 'r', encoding='Shift_JIS') as file:
5
- # 略
5
+ # 略
6
-
7
- path = fn + '_ret.csv' # 適当な別ファイル名
8
- with open(path, 'w', encoding='Shift_JIS') as file:
6
+ data = ','.join([str(max),str(min),str(avg)])
9
- dataWriter = csv.writer(file)
10
- dataWriter.writerow(max,min,avg)
7
+ fout.write(data + '\n')
11
8
  ```
12
9