From 7c66053e0275797f9fa99c81ccdb10e388da3cb0 Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Mon, 10 Jan 2011 14:12:33 +0100 Subject: improving the aligncsv.py script --- aligncsv.py | 48 +++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/aligncsv.py b/aligncsv.py index ce63a98..54bcd9d 100755 --- a/aligncsv.py +++ b/aligncsv.py @@ -33,10 +33,11 @@ for x in range(length): #find the longest entry in each line in each position for lineno in range(len(lines)): - sp=lines[lineno].split(",") - for pieceno in range(len(sp)): - sp[pieceno] = sp[pieceno].strip() + "," #for the comma add a char - textarray[-1][pieceno] = max(len(sp[pieceno]),textarray[-1][pieceno]) + if not lines[lineno].strip().startswith("//") or lines[lineno].strip().startswith("//id"): + sp=lines[lineno].split(",") + for pieceno in range(len(sp)): + sp[pieceno] = sp[pieceno].strip() + "," #for the comma add a char + textarray[-1][pieceno] = max(len(sp[pieceno]),textarray[-1][pieceno]) if tabs: #make it divisable by 8 (tabs work then) @@ -45,24 +46,29 @@ if tabs: textarray[-1][pieceno] = (((textarray[-1][pieceno])/8)*8)+8 for lineno in range(len(lines)): - sp=lines[lineno].split(",") - for pieceno in range(length): - textarray[lineno][pieceno] = "" - if pieceno