]> git.lyx.org Git - lyx.git/commitdiff
Update csv2lyx.py to work with Python 3.
authorPavel Sanda <sanda@lyx.org>
Wed, 8 Mar 2023 21:26:04 +0000 (22:26 +0100)
committerPavel Sanda <sanda@lyx.org>
Wed, 8 Mar 2023 21:26:04 +0000 (22:26 +0100)
Patch from Jose.

lib/scripts/csv2lyx.py

index 27063235c9040f4ff1fdaecaa463733b8aa2d0f0..4547c7d1c4a3311336e39334e3cb70ff5e448295 100644 (file)
@@ -164,21 +164,21 @@ if options.column_sep == 't':
 
 # when no special column separator is given, try to detect it:
 if options.column_sep and dialect :
-    reader = csv.reader(open(infile, "rU"), dialect = dialect, delimiter = options.column_sep)
+    reader = csv.reader(open(infile), dialect = dialect, delimiter = options.column_sep)
 else:
     guesser = csv.Sniffer()
-    input_file = "".join(open(infile,'rU').readlines())
+    input_file = "".join(open(infile).readlines())
     try:
         dialect = guesser.sniff(input_file)
-        reader = csv.reader(open(infile, "rU"), dialect = dialect)
+        reader = csv.reader(open(infile), dialect = dialect)
     except:
         # older versions (python < 2.5) of csv have problems (bugs)
         # that is why we try harder to get a result, this should work on most cases
         # as it assumes that the separator is a comma (the c in csv :-) )
         try:
-            reader = csv.reader(open(infile, "rU"), dialect = dialect, delimiter = ',')
+            reader = csv.reader(open(infile), dialect = dialect, delimiter = ',')
         except:
-            reader = csv.reader(open(infile, "rU"), delimiter = ',')
+            reader = csv.reader(open(infile), delimiter = ',')
 
 # read input
 num_cols = 1 # max columns