diff MoinMoin/parser/text_csv.py @ 3641:00af8e564f96 SOC2008-START

parser.text_csv: removes empty lines in front of the csv table
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sun, 25 May 2008 00:43:25 +0200
parents 75db5e7c09e2
children 8fbdd3667488
line wrap: on
line diff
--- a/MoinMoin/parser/text_csv.py	Sat May 24 23:17:45 2008 +0200
+++ b/MoinMoin/parser/text_csv.py	Sun May 25 00:43:25 2008 +0200
@@ -55,6 +55,17 @@
 
         # workaround csv.reader deficiency by encoding to utf-8
         data = raw.encode('utf-8').split('\n')
+
+        # workaraound to remove empty lines in front of the csv table
+        # if this is not done this parser shows only an empty line
+        count = 0
+        for txt in data:
+            if not txt:
+                count += 1
+            else:
+                data = data[count:]
+                break
+
         delimiter = ';'
         # Previous versions of this parser have used only the delimiter ";" (by default).
         # This version now tries to sniff the delimiter from the list preferred_delimiters
@@ -64,7 +75,7 @@
         # return a whitespace as delimiter.
         if data[0]:
             try:
-                preferred_delimiters =  [',', '\t', ';', ' ', ':']
+                preferred_delimiters = [',', '\t', ';', ' ', ':']
                 delimiter = Sniffer().sniff(data[0], preferred_delimiters).delimiter or ';'
             except Error:
                 pass