Skip to content

Test - and catch - .csv formatting (XML allowed chars) #17

@davidverweij

Description

@davidverweij

In the original code, I implemented try-except to check if the merge_pages was executed successfully. This was removed at #4.

try:
    docx.merge_pages([single_document])
except ValueError:
    print ("ValueError in document number " + str(counter) + ". Please check the .csv for valid characters. Continuing with the rest...")
except:
    print("Uknown Error")
    raise
else:
     docx.write(str(counter) + ".docx")

The docx.merge_pages() will fail if the .csv contains characters such as ä. See more details in the XML documentation. We should test if this still occurs - and then handle this error gracefully (e.g. try-except).

If this error still occurs, I'd suggest to continue conversion (csv2docx) and return a list of problematic rows in the .csv (perhaps with text output). In the module, this could be a list that convert() would return - which the CLI can print to the monitor.

Metadata

Metadata

Assignees

No one assigned

    Labels

    testingTests or test improvements to increase the rigidity of the repo

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions