Skip to content

Instantly share code, notes, and snippets.

@Lakshmi-1212
Created June 7, 2022 07:00
Show Gist options
  • Save Lakshmi-1212/4215732b462aacb70adec1fe4264c456 to your computer and use it in GitHub Desktop.
Save Lakshmi-1212/4215732b462aacb70adec1fe4264c456 to your computer and use it in GitHub Desktop.
def read_file(filepath, use_method = 'textract'):
text = ""
if not os.path.isfile(filepath):
print(f'Invalid file:{filepath}')
else:
if use_method == 'textract':
return read_file_textract(filepath)
elif use_method == 'pypdf':
return read_file_pypdf(filepath)
else:
print('Invalid method to read file. Supported formats: "textract" or "pypdf".')
return text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment