Ok, i've a script that will take a tab delimited string and reformat it so that all the blanks are at the end of the list.
So for example if you have the following string
Jack Black\tHollywood\t\tCalifornia\tAmerica
it would reformat the string to be
Jack Black\tHollywood\tCalifornia\tAmerica\t
Instead of giving me back a reformated tab delimited string as above, the result is as follows
Jack BlackHollywodCaliforniaAmerica
Anyway here's the commented code
So for example if you have the following string
Jack Black\tHollywood\t\tCalifornia\tAmerica
it would reformat the string to be
Jack Black\tHollywood\tCalifornia\tAmerica\t
Instead of giving me back a reformated tab delimited string as above, the result is as follows
Jack BlackHollywodCaliforniaAmerica
Anyway here's the commented code
Code:
##########################################################
# Common code to despace address lines
# Author : Paul Statham
# Date : 14/07/2006
#
# Version: 1.0
##########################################################
from techrtime import *
from sys import *
import string
techprint_address = techvars.full_address
def comp(x,y):
if x == y:
return 0
elif x == '':
return 1
elif y == '':
return -1
else:
return 0
def format_address():
final_address = ""
#Split the string into a list delimiting on the tab character
address_list = techprint_address.split('\t')
address_list.sort(comp)
for current in address_list:
if current == "":
final_address += '\t'
else:
final_address += current
techvars.full_address = final_address
return techvars.full_address