Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import sys
- import csv
- text = sys.stdin
- text = text.readlines()
- csvreader = csv.reader(text, delimiter=',', quotechar='"')
- rowcnt = 0
- for row in csvreader:
- if rowcnt == 0:
- num_cols = len(row)
- outrow = '|'.join(row)
- outformat = '|{}|'.format(outrow)
- print outformat
- head = '|-------' * num_cols
- head = '{}|'.format(head)
- print head
- else:
- outrow = '|'.join(row)
- outformat = '|{}|'.format(outrow)
- outformat.strip()
- print outformat
- rowcnt += 1
Add Comment
Please, Sign In to add comment