Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # csvstuff.py
- """ csvstuff.py
- ..A Python 2.67+ program
- Purpose: summarize csv blast report with all matching seq annotations
- Steven D. Irvin 09 Dec, 2011
- """
- import sys
- import re
- import csv
- def main():
- in_file = sys.argv[1]
- f = open(in_file, 'rt')
- output = re.sub('.csv', '.myreport.txt', in_file)
- fo = open(output, 'w')
- g = open(sys.argv[2], 'rt')
- mylists = []
- mynewlists = []
- mymissingitems = []
- try:
- reader = csv.DictReader(f)
- for row in reader:
- print(row)
- finally:
- f.close()
- try:
- greader = csv.DictReader(g)
- for grow in greader:
- print(grow)
- finally:
- g.close()
- for elements in mynewlists:
- if elements not in mylists:
- mymissingitems.append(elements)
- print(elements)
- fo.write('missing from file two,in file one' + '\n')
- fo.write(elements)
- fo.write('\n')
- fo.close()
- return 0 # success
- if __name__ == '__main__':
- status = main()
- sys.exit(status)
Add Comment
Please, Sign In to add comment