Skip to content

Instantly share code, notes, and snippets.

@RaghavSood
Created April 8, 2014 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RaghavSood/10209367 to your computer and use it in GitHub Desktop.
Save RaghavSood/10209367 to your computer and use it in GitHub Desktop.
import os
import sys
subfolders = 70
basepath = "/Users/raghavsood/Downloads/Elections/Delhi/"
currentfolder = 1
directory = "/Users/raghavsood/Downloads/Elections/Delhi/Analysed/"
try:
os.makedirs(directory)
except OSError:
pass # already exists
while currentfolder <= subfolders:
path = basepath + str(currentfolder).zfill(3) + "/"
print path
counter = 0
for filename in os.listdir(path):
#if counter >= 5:
# sys.exit("Done")
if filename[-4:] == '.pdf':
counter += 1
pdfpath = path + filename
print "Decoding " + filename
os.system("pdftotext -nopgbrk " + pdfpath + " " + directory + filename[:-4] + ".txt " )
currentfolder += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment