csv2lyx.py not working with python3??

José Matos jaomatos at gmail.com
Tue Mar 7 08:46:34 UTC 2023


On Mon, 2023-03-06 at 15:04 -0500, Neal Becker wrote:
>  python3 -tt /usr/share/lyx/scripts/csv2lyx.py all_results-2023-03-
> 06T13:58:32-0.csv all_results-2023-03-06T13:58:32-0.lyx
> Traceback (most recent call last):
>   File "/usr/share/lyx/scripts/csv2lyx.py", line 170, in <module>
>     input_file = "".join(open(infile,'rU').readlines())
>                          ^^^^^^^^^^^^^^^^^
> ValueError: invalid mode: 'rU'
> 
>  python2 -tt /usr/share/lyx/scripts/csv2lyx.py all_results-2023-03-
> 06T13:58:32-0.csv all_results-2023-03-06T13:58:32-0.lyx
> [silence...]
> 
> -- 
> Those who don't understand recursion are doomed to repeat it

Simplest solution, remove all the 'rU' arguments for open in the
script.

Rationale: 'r' is the read mode, default, 'U' is for the universal
newlines mode (for backwards compatibility; should not be used in new
code) [https://docs.python.org/2/library/io.html#io.open].


The attached path does precisely that, removes all the 'rU' arguments
in `open`. I tested it with some random csv file (the Stocks file from
matplotlib) and the outcome is the same for python 2 and 3. Due to the
change required for me that is more than good enough validation. :-)

Best regards,
-- 
José Abílio
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix_csv2lyx.patch
Type: text/x-patch
Size: 1449 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20230307/d78be539/attachment-0001.bin>


More information about the lyx-devel mailing list