Question: CAN SOMEONE MAKE THIS SO THAT USERS CAN ALTER THE .CSV FILE THROUGH A MENU? (PYTHON) #Import libraries from __future__ import with_statement import csv user_input
CAN SOMEONE MAKE THIS SO THAT USERS CAN ALTER THE .CSV FILE THROUGH A MENU? (PYTHON) #Import libraries
from __future__ import with_statement import csv user_input = ""
#Define a method def csv_reader(fobj): #Define readerA reader = csv.DictReader(fobj, delimiter=',') #Loop until length for line in reader: #Display print(line["surname"], line["last name"], line["landmark"], line["city"])
if __name__=="__main__": #Open file with open("data.csv") as fobj:
#Call method csv_reader(fobj)
#Define a method def csv_writer(data, path):
#Open file with open(path, "wb") as csv_file:
#Call method writer = csv.writer(csv_file, delimiter=",")
#Loop until length for line in data:
#Call method writer.writerow(line) def menu(): print("Press 'p' to print: ") print("Press 'e' to exit: ") user_input(input("Enter your choice: "))
if __name__ == "__main__": #menu() data = ["StreetNumber, surname, lastname, Landmark ,city".split(",") ,"1,Fred, Flintstone,301 Cobblestone way, Bedrock".split(','), "2, Richie, Rich, 126 Money Blvd, Los Angeles".split(","),"3,Henry, Phillips, 145 SVL Box, Victorville".split(',')] #Define path path = "output.csv" #Call method csv_writer(data, path)
#Declare list my_list = [] #Set name fieldnames = data[0]
#Loop until length for values in data[1:]: #Call method inner_dict = dict(zip(fieldnames, values)) #Append my_list.append(inner_dict)
#Define path path = "dict_output.csv" #Call method csv_writer(fieldnames,path)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
