Created
July 5, 2016 15:01
-
-
Save evz/c923fb5ac584f80345dfaf2ca69fb2ca to your computer and use it in GitHub Desktop.
Download and extract data about CPS lead tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import sys | |
from io import StringIO | |
import csv | |
if __name__ == "__main__": | |
proc = subprocess.Popen(['java', | |
'-jar', | |
'../tabula-java/target/tabula-0.9.0-jar-with-dependencies.jar', | |
'--pages', | |
'all', | |
'-r', | |
'Individualschool_Beasley.pdf'], stdout=subprocess.PIPE) | |
output, error = proc.communicate() | |
output_string = output.decode('utf-8') | |
begin = output_string.find('Sample ID') | |
end = output_string.find('EPA ACTION LEVEL') | |
part_we_want = output_string[begin:end] | |
first_part = output_string[:begin] | |
print(first_part) | |
reader = csv.reader(StringIO(part_we_want)) | |
with open('beasley.csv', 'w') as f: | |
writer = csv.writer(f) | |
writer.writerows(reader) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment