joseleeph

Untitled

Dec 7th, 2020
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. from sys import argv, exit
  2. import csv
  3. import re
  4. if len(argv) < 2:
  5. print("mising command-line argument")
  6. exit(1)
  7. pattern = "name"
  8. with open(argv[1], newline = '') as csvfile:
  9. print("using reader()")
  10. myreader = csv.reader(csvfile, delimiter = ' ')
  11. for row in myreader:
  12. if (row == "name"):
  13. print("using DictReader()")
  14. dicread = csv.DictReader(csvfile)
  15. for row in dicread:
  16. print(row['rowi'], row['rowj'])
Advertisement
Add Comment
Please, Sign In to add comment