mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
csv2lyx: use universal newlines when reading CSVs
Patch from Dustin J. Mitchell.
This commit is contained in:
parent
2ec8880e47
commit
b36b59d06a
@ -165,21 +165,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, "rb"), dialect = dialect, delimiter = options.column_sep)
|
||||
reader = csv.reader(open(infile, "rU"), dialect = dialect, delimiter = options.column_sep)
|
||||
else:
|
||||
guesser = csv.Sniffer()
|
||||
input_file = "".join(open(infile,'rb').readlines())
|
||||
input_file = "".join(open(infile,'rU').readlines())
|
||||
try:
|
||||
dialect = guesser.sniff(input_file)
|
||||
reader = csv.reader(open(infile, "rb"), dialect = dialect)
|
||||
reader = csv.reader(open(infile, "rU"), 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, "rb"), dialect = dialect, delimiter = ',')
|
||||
reader = csv.reader(open(infile, "rU"), dialect = dialect, delimiter = ',')
|
||||
except:
|
||||
reader = csv.reader(open(infile, "rb"), delimiter = ',')
|
||||
reader = csv.reader(open(infile, "rU"), delimiter = ',')
|
||||
|
||||
# read input
|
||||
num_cols = 1 # max columns
|
||||
|
@ -61,6 +61,8 @@ What's new
|
||||
|
||||
- Support (black) card suites in text mode (bug 8971).
|
||||
|
||||
- Use universal newlines when reading CSVs
|
||||
|
||||
|
||||
* USER INTERFACE
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user