December 2018
Intermediate to advanced
226 pages
4h 57m
English
Once in a while, we need to work on stored data or store some data from a script. For this purpose, we use file-handling techniques.
Consider the example for handling data storage (as a record) :
getinput=input("Do you want to store a new record (Y/N) ")#this is to remove any extra spaces getinput=getinput.strip()#this is to convert all input to lower case getinput=getinput.lower()#read values and create a record if ("y" in getinput): readvaluename=input("Enter the Name: ") readvalueage=input("Enter the Age: ") readvaluelocation=input("Current location: ") tmpvariable=readvaluename+","+readvalueage+","+readvaluelocation+"\n"### open a file myrecord.csv in write mode, write the record and close it fopen=open("myrecord.csv","w") ...Read now
Unlock full access