Skip to main content

extract_office_content

PyPI

Use

  1. Installextract_office_content
    $ pip install extract_office_content
    
  2. Run by CLI.
    • Extract All office file's content.
      $ extract_office_content -h
      usage: extract_office_content [-h] [-img_dir SAVE_IMG_DIR] file_path
      
      positional arguments:
      file_path
      
      optional arguments:
      -h, --help            show this help message and exit
      -img_dir SAVE_IMG_DIR, --save_img_dir SAVE_IMG_DIR
      
      $ extract_office_content tests/test_files
      
    • Extract Word.
      $ extract_word -h
      usage: extract_word [-h] [-img_dir SAVE_IMG_DIR] word_path
      
      positional arguments:
      word_path
      
      optional arguments:
      -h, --help            show this help message and exit
      -img_dir SAVE_IMG_DIR, --save_img_dir SAVE_IMG_DIR
      
      $ extract_word tests/test_files/word_example.docx
      
    • Extract PPT.
      $ extract_ppt -h
      usage: extract_ppt [-h] [-img_dir SAVE_IMG_DIR] ppt_path
      
      positional arguments:
      ppt_path
      
      optional arguments:
      -h, --help            show this help message and exit
      -img_dir SAVE_IMG_DIR, --save_img_dir SAVE_IMG_DIR
      
      $ extract_ppt tests/test_files/ppt_example.pptx
      
    • Extract Excel.
      $ extract_excel -h
      usage: extract_excel [-h] [-f {markdown,html,latex,string}] [-o SAVE_IMG_DIR]
                          excel_path
      
      positional arguments:
      excel_path
      
      optional arguments:
      -h, --help            show this help message and exit
      -f {markdown,html,latex,string}, --output_format {markdown,html,latex,string}
      -o SAVE_IMG_DIR, --save_img_dir SAVE_IMG_DIR
      
      $ extract_excel tests/test_files/excel_example.xlsx
      
  3. Run by python script.
    • Extract all.
      from pathlib import Path
      from extract_office_content import ExtractOfficeContent
      
      
      extracter = ExtractOfficeContent()
      
      file_list = list(Path('tests/test_files').iterdir())
      
      for file_path in file_list:
          res = extracter(file_path)
          print(res)
      
    • Extract Word.
      from extract_office_content import ExtractWord
      
      word_extract = ExtractWord()
      
      word_path = 'tests/test_files/word_example.docx'
      text = word_extract(word_path, "outputs/word")
      
      # or bytes
      with open(word_path, 'rb') as f:
          word_content = f.read()
      text = word_extract(word_content, "outputs/word")
      print(text)
      
    • Extract PPT.
      from pathlib import Path
      
      from extract_office_content import ExtractPPT
      
      ppt_extracter = ExtractPPT()
      
      ppt_path = 'tests/test_files/ppt_example.pptx'
      save_dir = 'outputs'
      save_img_dir = Path(save_dir) / Path(ppt_path).stem
      res = ppt_extracter(ppt_path, save_img_dir=str(save_img_dir))
      
      # or bytes
      with open(ppt_path, 'rb') as f:
          ppt_content = f.read()
      res = ppt_extracter(ppt_content, save_img_dir=str(save_img_dir))
      print(res)
      
    • Extract Excel.
      from extract_office_content import ExtractExcel
      
      excel_extract = ExtractExcel()
      
      excel_path = 'tests/test_files/excel_with_image.xlsx'
      res  = excel_extract(excel_path, out_format='markdown', save_img_dir='1')
      
      # or
      with open(excel_path, 'rb') as f:
          excel_content = f.read()
      res  = excel_extract(excel_content, out_format='markdown', save_img_dir='1')
      print(res)
      

See details for ExtractOfficeContent.

Metadata

Release files for extract-office-content 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for extract-office-content 0.0.7
File Interpreter ABI Platform
extract_office_content-0.0.7-py3-none-any.whl Python 3 none any Details

Release files / extract_office_content-0.0.7-py3-none-any.whl

Download URL extract_office_content-0.0.7-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8d5bc5f7bb5a8dc90d596d95bdd65aa43787b060345626130f23a24e58b98c85
BLAKE2b-256 checksum
How to use checksums
00a83c3de77223cba5b5bafa9dc8f2fed86b0c2fc994ef493c55f249072c9c44
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17

Release history Release notifications | RSS feed

This release

0.0.7 This release

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page