from prettytable import from_csv
import csv
n = int(input('Введите кол-во наименований: '))
name = 'Названия продукции'
kol = 'Количество продукции'
k = []
m = []
k.append(name)
m.append(kol)
for i in range(n):
q = input('Введите название: ')
v = input('Кол-во: ')
k.append(q)
m.append(v)
with open('file.csv','w', newline = '') as csvfile:
writer = csv.writer(csvfile, delimiter = ';')
writer.writerow(k)
writer.writerow(m)
with open('file.csv') as csvfile:
table = from_csv(csvfile)
print(table)
headers = ['Название продукции', 'Количество продукции']
n = int(input('Введите кол-во наименований: '))
with open('file.csv', 'w', newline = '') as csvfile:
writer = csv.writer(csvfile, delimiter = ';')
writer.writerow(headers)
for _ in range(n):
name = input('Введите название: ')
count = input('Кол-во: ')
writer.writerow([name, count])