Skip to content

UnicodeDecodeError in logger.info during the execution of partition_doc #2449

Closed

Description

@MinnyKuan

hi,
I'm using version 0.11.8.
I use the following code to execute partition_doc :


from unstructured.partition.doc import partition_doc

filename = ""D:\\Testcase\\test.doc""
elements = partition_doc(filename=filename)

However, I encountered a UnicodeDecodeError occurring while executing convert_office_doc in logger.info(output.decode().strip())
The error message is as follows:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xaa in position 38: invalid start byte

Activity

  1. added
    bug
    on Jan 24, 2024
  2. MthwRobinson commented on Jan 24, 2024

    @MthwRobinson
    Contributor

    @MinnyKuan - Any chance you can share the file that causes the error?

  3. MinnyKuan commented on Jan 25, 2024

    @MinnyKuan
    Author

    Sure, because I cannot upload a doc file here, I used a compressed file.
    This is a compressed file of a doc document:
    test.zip

  4. MthwRobinson commented on Jan 25, 2024

    @MthwRobinson
    Contributor

    Thanks @MinnyKuan ! We'll look into this as soon as we can

  5. MthwRobinson commented on Feb 6, 2024

    @MthwRobinson
    Contributor

    Hi @MinnyKuan - I was able to process the example doc using partition_doc on a Mac. Are you able to try this on Mac or Linux? From your example code it looks like you're on Windows.

  6. MinnyKuan commented on Feb 23, 2024

    @MinnyKuan
    Author

    I tried this on Linux
    The doc file shows the following error message, but the docx file does not.

    Error: source file could not be loaded
    PackageNotFoundError                      Traceback (most recent call last)
    PackageNotFoundError: Package not found at '/tmp/tmp138uvpct/test.docx'
    

    image

    I also tried using the UnstructuredFileLoader method, but the result was the same.
    From my understanding, convert_office_doc converts the doc file to a docx file and then reads it. However, after converting it to a docx file, the file cannot be found.Could it be related to the parameters used in the saveAs function during the conversion from doc to docx?
    I am currently still searching for a solution.

    ps.
    I have already installed LibreOffice and LibreOffice Writer

  7. srjchauhan commented on Apr 20, 2024

    @srjchauhan
    Contributor

    @MinnyKuan is this still a issue for you? I was able to process the example doc using partition_doc on my linux

  8. self-assigned this
    on Apr 20, 2024
  9. added
    docx
    on Apr 20, 2024
  10. MinnyKuan commented on Apr 22, 2024

    @MinnyKuan
    Author

    @scanny
    Yes, but currently I am converting the doc files to docx format locally before reading them. This allows me to continue using them.

  11. scanny commented on Apr 22, 2024

    @scanny
    Contributor

    @MinnyKuan A couple things:

    1. If you have already converted a document from .doc to .docx, you will need to call partition_docx(...) rather than partition_doc(...).
    2. Please post a minimum-reproducible-example that produces this problem in your environment: https://stackoverflow.com/help/minimal-reproducible-example
    3. Post the entire stack trace you receive, not just the error message on the last line. This will allow us to pinpoint where the error is occuring.

    If you can provide those I'll take a look :)

  12. scanny commented on Apr 27, 2024

    @scanny
    Contributor

    Closing as cannot reproduce, assumed resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugdocx

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions