Guest User

Untitled

a guest
Jul 17th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. #-*- coding: utf-8 -*-
  3.  
  4. group = 'Personal'
  5. header = 'name,username,password,url,extra,grouping'
  6.  
  7.  
  8. def main(filename):
  9. with open(filename, 'r') as f:
  10. with open('output.csv', 'w') as o:
  11. cnt = 0
  12. for l in f:
  13. if cnt == 0:
  14. line = header
  15. o.write(line + '\n')
  16. else:
  17. add = ',"{}"'.format(group)
  18. line = l.rstrip('\n') + add + '\n'
  19. print(line)
  20. o.write(line)
  21. cnt += 1
  22.  
  23.  
  24. if __name__ == '__main__':
  25. filename = input('Enter the name or path of the file: ')
  26. main(filename)
Add Comment
Please, Sign In to add comment