Please refer to the picture linked above. I have an email report showing negative values with parentheses around them. I need to make it do that the last digit in each number lines up with each other. The values are being printing by using for-loops and if-statements when running SQL statements. The values are printed as they run through the SQL statements.
How do I get the positive values to shift once to the left to align with the last digit of the numbers in parentheses?
Here are the for loops that print the columns in the report:
# write the lines, one to each row
for line in curs: # row
rowTotal = 0
rowProd = 0
rowStr=''
for c in range(len(line)): # iterate column
if line[c]:
if colFormat[c] == 'S':
rowStr += str(line[c]).ljust(justlen[c],'.')
else:
columnTotal[c]+=line[c]
rowTotal += line[c]
if rowProd == 0:
rowProd += line[c]
else:
rowProd *= line[c]
rowStr += round_dolls(line[c], justlen[c], colFormat[c], zeroChar)
else: #lince[c] is None
if c < numOfHead: # for header part, put N/a
rowStr += 'N/A'.ljust(justlen[c],'.')
else: # for value put the character specified in zeroChar
rowStr += zeroChar.rjust(justlen[c],'.')
rowProd = 0
Aucun commentaire:
Enregistrer un commentaire