Advertisement
Guest User

Untitled

a guest
May 24th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #!/usr/bin/env python2.7
  2. # encoding: utf-8
  3.  
  4. ## Get filings from master list
  5. ## Available here: ftp://ftp.sec.gov/edgar/full-index/
  6. ## Jasper GInn
  7. ## 07/05/2016
  8.  
  9. ## Call function from terminal
  10. ## python processMasterFilings.py </path/to/master/list> </path/to/output/csv> <document type>
  11.  
  12. import sys
  13.  
  14. # Class
  15.  
  16. class processFilings:
  17.  
  18. def __init__(self, file_path_input, file_path_output):
  19. self.file_path_input = file_path_input
  20. self.file_path_output = file_path_output
  21.  
  22. def filterFilings(self, filing):
  23. # Open input
  24. with open(self.file_path_input, 'r') as filings:
  25. for line in filings:
  26. if "|10-K|" in line:
  27. elements = line.split("|")
  28. with open(self.file_path_output, 'a') as outfile:
  29. outfile.write("{};{};{};{};ftp://ftp.sec.gov/{}".format(elements[0],elements[1].replace(",", ""),elements[2],elements[3],elements[4]))
  30.  
  31. # Run
  32. if __name__ == "__main__":
  33. infile = sys.argv[1]
  34. outfile = sys.argv[2]
  35. filing = sys.argv[3]
  36. # Call
  37. p = processFilings(infile, outfile)
  38. # Read/write
  39. p.filterFilings(filing)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement