From 7a7eede9803468f5c6e260e3b4f9c7b1aef6ca3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Matox?= Date: Thu, 18 Sep 2008 18:21:41 +0000 Subject: [PATCH] Replace condition with an exception (code more robust) and add comment the reason git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26450 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/scripts/csv2lyx.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/scripts/csv2lyx.py b/lib/scripts/csv2lyx.py index 65632d95f0..0002144461 100644 --- a/lib/scripts/csv2lyx.py +++ b/lib/scripts/csv2lyx.py @@ -149,9 +149,12 @@ else: dialect = guesser.sniff(input_file) reader = csv.reader(open(infile, "rb"), dialect = dialect) except: - if dialect: + # 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 = ',') - else: + except: reader = csv.reader(open(infile, "rb"), delimiter = ',') # read input