Guest User

Untitled

a guest
Feb 24th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import sys
  4. import csv
  5.  
  6. text = sys.stdin
  7. text = text.readlines()
  8. csvreader = csv.reader(text, delimiter=',', quotechar='"')
  9. rowcnt = 0
  10. for row in csvreader:
  11. if rowcnt == 0:
  12. num_cols = len(row)
  13. outrow = '|'.join(row)
  14. outformat = '|{}|'.format(outrow)
  15. print outformat
  16. head = '|-------' * num_cols
  17. head = '{}|'.format(head)
  18. print head
  19. else:
  20. outrow = '|'.join(row)
  21. outformat = '|{}|'.format(outrow)
  22. outformat.strip()
  23. print outformat
  24. rowcnt += 1
Add Comment
Please, Sign In to add comment