Skip to content

Commit

Permalink
Fix critical IO fail when running as a package
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerdq committed Aug 12, 2019
1 parent 5e876f6 commit acf5871
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pdfca.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def load_df(binary):

def save_df(data_frame, binary):
"""Save dataframe to local Feather binary"""
os.chdir(sys.path[0])
if binary.endswith('.feather'):
click.secho(f'Saving "{binary}"...', fg='cyan')
feather.write_feather(data_frame, binary)
Expand Down Expand Up @@ -102,6 +101,7 @@ def extract(directory, binary, format):
Use "./" as DIRECTORY to process files in the pdfca folder."""
binary = binary + format
load_df(binary)
cwd = os.getcwd()
os.chdir(directory)
pdfs = glob.glob('*.pdf')
if click.confirm(click.style(f'Ready to get text from {len(pdfs)} ' +
Expand Down Expand Up @@ -131,8 +131,7 @@ def extract(directory, binary, format):
total = total + 1
if exceptions:
print(f'Errors with text on {len(exceptions)} pages.')
save_df(df, binary)
os.chdir(directory)
save_df(df, f'{cwd}\\{binary}')
click.secho(f'Extracted and saved {total} total pages.',
fg='bright_green')
else:
Expand Down

0 comments on commit acf5871

Please sign in to comment.