daily pastebin goal
55%
SHARE
TWEET

Untitled

a guest Jun 14th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2. # csvstuff.py
  3. """ csvstuff.py
  4.     ..A Python 2.67+ program
  5.     Purpose: summarize csv blast report with all matching seq annotations
  6.      Steven D. Irvin 09 Dec, 2011
  7. """
  8.  
  9. import sys
  10. import re
  11. import csv
  12.  
  13.  
  14. def main():
  15.     in_file = sys.argv[1]
  16.     f = open(in_file, 'rt')
  17.     output = re.sub('.csv', '.myreport.txt', in_file)
  18.     fo = open(output, 'w')
  19.     g = open(sys.argv[2], 'rt')
  20.     mylists = []
  21.     mynewlists = []
  22.     mymissingitems = []
  23.     try:
  24.         reader = csv.DictReader(f)
  25.         for row in reader:
  26.             print(row)
  27.     finally:
  28.         f.close()
  29.        
  30.     try:
  31.         greader = csv.DictReader(g)
  32.         for grow in greader:
  33.             print(grow)
  34.     finally:
  35.         g.close()
  36.  
  37.     for elements in mynewlists:
  38.         if elements not in mylists:
  39.             mymissingitems.append(elements)
  40.             print(elements)
  41.             fo.write('missing from file two,in file one' + '\n')
  42.             fo.write(elements)
  43.             fo.write('\n')
  44.     fo.close()
  45.    
  46.     return 0        # success
  47.  
  48. if __name__ == '__main__':
  49.     status = main()
  50.     sys.exit(status)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top