From ed81f91ac3c470e00df0d5c5cf9c274ce30f47b3 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Fri, 16 Sep 2011 14:36:23 -0700 Subject: Reimplement aligncsv in C++ instead of python. The main advantage of the new one is that it properly handles {script arg1, arg2;} --- tools/aligncsv.py | 88 ------------------------------------------------------- 1 file changed, 88 deletions(-) delete mode 100755 tools/aligncsv.py (limited to 'tools/aligncsv.py') diff --git a/tools/aligncsv.py b/tools/aligncsv.py deleted file mode 100755 index 54bcd9d4..00000000 --- a/tools/aligncsv.py +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/python -# this formats a csv file to a serious whitespace intended format. - -import os -import sys - -tabs=True -additionalspaces = 5 - -fname = sys.argv[1] -if not os.path.exists(fname): - print "that file doesn't exist" - exit(0); - -f=open(fname,"r"); -lines=f.readlines() -f.close(); -length=0 - -for line in lines: - length=max(length, len(line.split(","))) - -print "# number of entries =",length - - -#setup text array -textarray=range(len(lines)+1) -for x in range(len(lines)+1): - textarray[x] = range(length) - -for x in range(length): - textarray[-1][x] = 0 - -#find the longest entry in each line in each position -for lineno in range(len(lines)): - 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) - for pieceno in range(length): - if (textarray[-1][pieceno] %8) !=0: - textarray[-1][pieceno] = (((textarray[-1][pieceno])/8)*8)+8 - -for lineno in range(len(lines)): - 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