Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown save result as file fails #52

Closed
rutsam opened this issue Oct 12, 2021 · 2 comments
Closed

Markdown save result as file fails #52

rutsam opened this issue Oct 12, 2021 · 2 comments
Labels

Comments

@rutsam
Copy link

rutsam commented Oct 12, 2021

Problem

In version 0.64.0 and version 0.63.0, whenever I want to save the markdown result in a file I get an error, I tried using python3.6 and python 3.8. The error comes when I use write.dumps or save file using stream and write table as it can be seen in the code below

preview of code that generates error

with open("sample.md", "w") as f:                                                                                           
writer.stream = f                                                                                                       
writer.write_table()  

Error

 File "result.py", line 51, in <module>
    main()
  File "result.py", line 42, in main
    publish_report(report, gral_values, "DIETClassifier")
  File "result.py", line 20, in publish_report
    writer.write_table()
  File "/home/.local/lib/python3.8/site-packages/pytablewriter/writer/text/_markdown.py", line 140, in write_table
    self._write_table(**kwargs)
  File "/home/.local/lib/python3.8/site-packages/pytablewriter/writer/text/_text_writer.py", line 322, in _write_table
    self._preprocess()
  File "/home/.local/lib/python3.8/site-packages/pytablewriter/writer/_table_writer.py", line 1193, in _preprocess
    self._preprocess_table_dp()
  File "/home/.local/lib/python3.8/site-packages/pytablewriter/writer/_table_writer.py", line 1130, in _preprocess_table_dp
    self._table_value_dp_matrix = self._dp_extractor.to_dp_matrix(
  File "/home/.local/lib/python3.8/site-packages/dataproperty/_extractor.py", line 483, in to_dp_matrix
    return self.__to_dp_matrix_st(value_matrix)
  File "/home/.local/lib/python3.8/site-packages/dataproperty/_extractor.py", line 633, in __to_dp_matrix_st
    zip(
  File "/home/.local/lib/python3.8/site-packages/dataproperty/_extractor.py", line 635, in <genexpr>
    _to_dp_list_helper(
  File "/home/.local/lib/python3.8/site-packages/dataproperty/_extractor.py", line 799, in _to_dp_list_helper
    extractor._to_dp_list(data_list, type_hint=type_hint, preprocessor=preprocessor),
  File "/home/.local/lib/python3.8/site-packages/dataproperty/_extractor.py", line 696, in _to_dp_list
    dataprop = self.__to_dp(
  File "/home/.local/lib/python3.8/site-packages/dataproperty/_extractor.py", line 568, in __to_dp
    return self.__to_dp_raw(
  File "/home/.local/lib/python3.8/site-packages/dataproperty/_extractor.py", line 619, in __to_dp_raw
    value_dp = DataProperty(
  File "/home/.local/lib/python3.8/site-packages/dataproperty/_dataproperty.py", line 89, in __init__
    data, no_ansi_escape_data = preprocessor.preprocess(data)
  File "/home/.local/lib/python3.8/site-packages/dataproperty/_preprocessor.py", line 68, in preprocess
    data, no_ansi_escape_data = self.__preprocess_string(
  File "/home/.local/lib/python3.8/site-packages/dataproperty/_preprocessor.py", line 105, in __preprocess_string
    data = self.__dequote(data)
  File "/home/.local/lib/python3.8/site-packages/dataproperty/_preprocessor.py", line 135, in __dequote
    if (s[0] == s[-1]) and s.startswith(("'", '"')):
  KeyError: 0

Stable version

From version 0.62.0 and lower the files were saved without any problem

@thombashi
Copy link
Owner

@rutsam
Thank you for your report.

Would you possibly provide the failed input data (sample.md) ?
I could not reproduce the error.
According to the error log, the error seems to occur only with certain input data.

@thombashi
Copy link
Owner

I believe the problem fixed at pytablewriter 0.64.1
Please try to upgrade the package.

Feel free to reopen if you still have any problems about the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants