Sir, your teaching is really awesome, you are real teacher who understand how to make things easy and deliver to student. I have seen multiple videos about sys.args but they were not explaining as you did. Thank you sir
Great Sir , but there are others operations like Truncating , Renaming , Removing a files are missing that all operations has module called "OS" module we need to import
hi sir i have scenario i have csv file with data i need to separate the file first three rows related to one table and rest is related to second table how can i write the script in python could you please help on this
both are same until you pass an argument which is essentially the number of characters. if you pass read() or readlines() both are same if you have read(5), it will read only first 5 characters of a file. for readlines() there is no argument needed as it gives you complete file
If there are multiple lines in a file, ex: f1=open("file1.txt","w") lines=["Welcome to ","Python Programming "] f1.write(lines) read() will return each line data as it is in the file Ex: Welcome to python Programming but readlines() will return each line as an element of list. Ex: ["Welcome to ","Python Programming "]
At 6:40 & 14:35, i wrote below code to write data in different lines, when i print it. it was written in a single line. i opened the file from CWD and there also its written in a single line. >>> f2=open("xyz.txt","w") >>> lines=["Hello","Welcome to","Python Programming"] >>> f2.writelines(lines) >>> f2.close() >>> f2=open("xyz.txt","r") >>> f2.readlines() and output is : ['HelloWelcome toPython Programming'] Why it is not writing data in multiple lines as i have used writelines() function.???
Great Video but please if any can help with this code def main(): #special formatting for the output PRE = '@' SEP = '***END*** ' toOut = input('Enter file name to output ') orderFile = open(toOut, 'w') goon = 'y' while goon == 'y': name = input('Enter the name ') orderFile.write(PRE+name+' ') #concats the PRE char to the name so we know it's a name in the output file num = 'not naut' #dummy value to start so the loop loops while num != '-1': #get sales for each person, uses -1 as a sentinel value to indicate we're done looping num = (input('Enter value or -1 to quit end for ' + name +' ')) #we don't want to write the sentinel to the file if num != '-1': orderFile.write(str(num) + ' ') orderFile.write(SEP) #after we're done with the sales for a person write the seperator to mark the end #if y we loop again for another person goon = input('Would you like to enter another person? y for yes ') main() Here is the result @Alice 19.99 13.33 123 321 ***END*** @Bobby 1 2 3 4 5 6 7 8 9 10 ***END*** @Cathy 3.33 2.22 1.11 ***END*** but how can I calculate the above each employee sales to show result like below @Alice $477.32 ***END*** @Bobby $55.00 ***END*** @Cathy $6.66 ***END***
Hi sir I have one doubt that If I am writing some data to file and want to read that data again How can I achieve this? As its write and read operation on same file and pointer shifting for each write operation.