summaryrefslogtreecommitdiff
path: root/tools/aligncsv.py
diff options
context:
space:
mode:
authorStefan Beller <stefanbeller@googlemail.com>2011-01-10 14:12:33 +0100
committerStefan Beller <stefanbeller@googlemail.com>2011-01-10 14:21:31 +0100
commitbc23ed45d729ebb053c9d23e136933e42ba75045 (patch)
treed0277d1edc4528323bb665d862c4b3d69c620836 /tools/aligncsv.py
parent374359ed51f7dfc1887cee0270193ca320c899bd (diff)
downloadserverdata-bc23ed45d729ebb053c9d23e136933e42ba75045.tar.gz
serverdata-bc23ed45d729ebb053c9d23e136933e42ba75045.tar.bz2
serverdata-bc23ed45d729ebb053c9d23e136933e42ba75045.tar.xz
serverdata-bc23ed45d729ebb053c9d23e136933e42ba75045.zip
improving the aligncsv.py script
Diffstat (limited to 'tools/aligncsv.py')
-rwxr-xr-xtools/aligncsv.py48
1 files changed, 27 insertions, 21 deletions
diff --git a/tools/aligncsv.py b/tools/aligncsv.py
index ce63a988..54bcd9d4 100755
--- a/tools/aligncsv.py
+++ b/tools/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<len(sp):
- sp[pieceno]= sp[pieceno].strip()
- if pieceno<len(sp)-1:
- sp[pieceno]= sp[pieceno] + ","
-
- if (tabs):
- n=(textarray[-1][pieceno]-len(sp[pieceno]))
- textarray[lineno][pieceno] = sp[pieceno]
- if (n%8) != 0:
- textarray[lineno][pieceno] += "\t"*((n/8)+1)
+ if not lines[lineno].strip().startswith("//") or lines[lineno].strip().startswith("//id"):
+ sp=lines[lineno].split(",")
+ for pieceno in range(length):
+ textarray[lineno][pieceno] = ""
+ if pieceno<len(sp):
+ sp[pieceno]= sp[pieceno].strip()
+ if pieceno<len(sp)-1:
+ sp[pieceno]= sp[pieceno] + ","
+
+ if (tabs):
+ n=(textarray[-1][pieceno]-len(sp[pieceno]))
+ textarray[lineno][pieceno] = sp[pieceno]
+ if (n%8) != 0:
+ textarray[lineno][pieceno] += "\t"*((n/8)+1)
+ else:
+ textarray[lineno][pieceno] += "\t"*((n/8))
else:
- textarray[lineno][pieceno] += "\t"*((n/8))
- else:
- n=(textarray[-1][pieceno]-len(sp[pieceno])+additionalspaces)
- textarray[lineno][pieceno] = " "*(n) + sp[pieceno]
+ n=(textarray[-1][pieceno]-len(sp[pieceno])+additionalspaces)
+ textarray[lineno][pieceno] = " "*(n) + sp[pieceno]
+ else:
+ for pieceno in range(length):
+ textarray[lineno][pieceno] = ""
+ textarray[lineno][0]=lines[lineno].strip()
fname = sys.argv[2]