From 97fd9bd940f06d0b86f8b2278ba28c1b581f3b64 Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Wed, 5 Jan 2011 23:27:25 +0100 Subject: now the alignment script works with tabs as well --- tools/aligncsv.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'tools/aligncsv.py') diff --git a/tools/aligncsv.py b/tools/aligncsv.py index 69e1d871..ce63a988 100755 --- a/tools/aligncsv.py +++ b/tools/aligncsv.py @@ -4,7 +4,8 @@ import os import sys -tabs=not True +tabs=True +additionalspaces = 5 fname = sys.argv[1] if not os.path.exists(fname): @@ -20,7 +21,7 @@ for line in lines: length=max(length, len(line.split(","))) print "# number of entries =",length -additionalspaces = 5 + #setup text array textarray=range(len(lines)+1) @@ -34,14 +35,14 @@ for x in range(length): for lineno in range(len(lines)): sp=lines[lineno].split(",") for pieceno in range(len(sp)): - sp[pieceno] = sp[pieceno].strip() + 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) for pieceno in range(length): - if textarray[-1][pieceno] %8: - textarray[-1][pieceno] = ((textarray[-1][pieceno]/8) *8) +8 + if (textarray[-1][pieceno] %8) !=0: + textarray[-1][pieceno] = (((textarray[-1][pieceno])/8)*8)+8 for lineno in range(len(lines)): sp=lines[lineno].split(",") @@ -51,11 +52,16 @@ for lineno in range(len(lines)): sp[pieceno]= sp[pieceno].strip() if pieceno