Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- #-*- coding: utf-8 -*-
- group = 'Personal'
- header = 'name,username,password,url,extra,grouping'
- def main(filename):
- with open(filename, 'r') as f:
- with open('output.csv', 'w') as o:
- cnt = 0
- for l in f:
- if cnt == 0:
- line = header
- o.write(line + '\n')
- else:
- add = ',"{}"'.format(group)
- line = l.rstrip('\n') + add + '\n'
- print(line)
- o.write(line)
- cnt += 1
- if __name__ == '__main__':
- filename = input('Enter the name or path of the file: ')
- main(filename)
Add Comment
Please, Sign In to add comment