Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def simple():
- with open("file.txt") as f:
- content = []
- for lines in f:
- content.append(lines.strip().split(","))
- doc_num, date, id, etc = content # define all the contents that are in a line
- # print(doc_num, date, id, etc)
- return doc_num, date, id, etc # Returns data
- def csv_version():
- """The same but working with csv.
- """
- import os
- import csv
- with open("test.csv", newline="") as f:
- reader = csv.reader(f)
- for line in reader:
- print(line)
- if __name__ == "__main__":
- choose = input("Use simple [1] or csv [2] : ")
- if choose == 1:
- simple()
- elif choose == 2:
- csv_version()
- else:
- return None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement