Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,22 @@
import csv
from pathlib import Path
from tempfile import NamedTemporaryFile
filepath = Path('data.csv')
temp_file = NamedTemporaryFile('w',
newline='',
delete=False)
with filepath.open() as csv_file, temp_file:
reader = csv.reader(csv_file)
writer = csv.writer(temp_file)
header = next(reader)
writer.writerow(header + ['SUM'])
for row in reader:
row_sum = sum(map(int, row))
writer.writerow(row + [row_sum])
temp_file_path = Path(temp_file.name)
temp_file_path.replace(filepath)