Mar-24-2020, 01:59 AM
Hey peeps,
How do you take user input and populate a .csv file?
I know Python reads top to bottom, so I was thinking I needed to create the headers first and then create blank writer lines to fill in, but I know that isn't the correct flow. What happens when there are 10,000 user input lines, this would be a mess. Table, Drink, Count, Cost, Tab act as headers and all user input is supposed to follow underneath.
As always, any suggestions are much appreciated!
Below is a truncated example of the project I am working on:
How do you take user input and populate a .csv file?
I know Python reads top to bottom, so I was thinking I needed to create the headers first and then create blank writer lines to fill in, but I know that isn't the correct flow. What happens when there are 10,000 user input lines, this would be a mess. Table, Drink, Count, Cost, Tab act as headers and all user input is supposed to follow underneath.
As always, any suggestions are much appreciated!
Below is a truncated example of the project I am working on:
import csv def bar(): file = open ('Bar_March.csv', 'w') writer = csv.writer(file) writer.writerow(['Table', 'Drink', 'Count', 'Cost', 'Tab']) writer.writerow(['']) writer.writerow(['']) table = input('Bar or Table? ') print(table) Drink = input('Refreshment? ') print(Drink)