Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # read a file
- # Bruce,91923291923,bruce@email.com
- # Alfred,3233123124,Alfred@mail.com
- with open("file_name.csv", "r") as file_variable:
- f = file_variable.read() # read complete file
- f = file_variable.readline() # read line by line line1
- f = file_variable.readline() # read line by line line2 # returns None when there is nothing left to read
- for line in file_variable: # read all lines one by one
- ls = line.split(",")
- with open("file_name.csv", "w") as file:
- file.write(name + "," + phone + "," + email)
- def saveContact(name, phone, email):
- with open("file_name.csv", "a") as file:
- file.write(name + "," + phone + "," + email + "\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement