How to convert a Word DOC 97–03 Document to Text TXT in Python

If you are having issues with obsolete DOC files from decades ago, then don’t worry, I am about to give you Python users a quick fix.

Our solution will be using the Cloudmersive Convert API, so let’s begin with installation of that:

pip install cloudmersive-convert-api-client

And now we need to call convert_document_doc_to_txt, which will require an API instance to work. This is simple, as you can see in this example code below.

from __future__ import print_functionimport timeimport cloudmersive_convert_api_clientfrom cloudmersive_convert_api_client.rest import ApiExceptionfrom pprint import pprint# Configure API key authorization: Apikeyconfiguration = cloudmersive_convert_api_client.Configuration()configuration.api_key['Apikey'] = 'YOUR_API_KEY'# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['Apikey'] = 'Bearer'# create an instance of the API classapi_instance = cloudmersive_convert_api_client.ConvertDocumentApi(cloudmersive_convert_api_client.ApiClient(configuration))input_file = '/path/to/file' # file | Input file to perform the operation on.try:# Convert Word DOC (97-03) Document to Text (txt)api_response = api_instance.convert_document_doc_to_txt(input_file)pprint(api_response)except ApiException as e:print("Exception when calling ConvertDocumentApi->convert_document_doc_to_txt: %s\n" % e)

Enter your file path, and you are good to go. Walk in the park, right?

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.