How can I subtract two values which I have got from a .txt file
Question: So far I have managed to print out certain parts of the `.txt` file in Python
however I cannot figure out how to subtract the amount paid from my total
amount and then add up the outstanding value from each column.

    
    
    import csv
    
    FILE_NAME = "paintingJobs.txt" #I use this so that the file can be used easier
    COL_HEADERS = ['Number', 'Date', 'ID', 'Total', 'Status', 'Paid']
    NUM_COLS = len(COL_HEADERS)#This will insure that the header of each column fits into the length of the data
    
    # read file once to determine maximum width of data in columns
    with open(FILE_NAME) as f:
        reader = csv.reader(f, delimiter=',')
        # determine the maximum width of the data in each column
        max_col_widths = [len(col_header) for col_header in COL_HEADERS]
        for columns in reader:
            for i, col in enumerate(columns):
                if "A" in columns and int(columns[5]) < int(columns[3]):
                    max_col_widths[i] = max(max_col_widths[i], len(repr(col)))
        # add 1 to each for commas
        max_col_widths = [col_width+1 for col_width in max_col_widths]
    
    # read file second time to display its contents with the headers
    with open(FILE_NAME) as f:
        reader = csv.reader(f, delimiter=',')
        # display justified column headers
        print(' ' + ' '.join(col_header.ljust(max_col_widths[i])
                                for i, col_header in enumerate(COL_HEADERS)))
        # display justified column data
        for columns in reader:
            if "A" in columns and int(columns[5]) < int(columns[3]):
                print(columns)`
    

This is the result so far:

    
    
     Number   Date          ID      Total   Status  Paid  
    ['E5345', '22/09/2015', 'C106', '815', 'A', '400']
    ['E5348', '23/09/2015', 'C109', '370', 'A', '200']
    ['E5349', '25/09/2015', 'C110', '480', 'A', '250']
    ['E5353', '28/09/2015', 'C114', '272', 'A', '200']
    ['E5355', '29/09/2015', 'C116', '530', 'A', '450']
    ['E5363', '01/10/2015', 'C124', '930', 'A', '500']
    ['E5364', '02/10/2015', 'C125', '915', 'A', '800']
    ['E5367', '03/10/2015', 'C128', '427', 'A', '350']
    ['E5373', '10/10/2015', 'C134', '1023', 'A', '550']
    

What i want to do is add a new column which is the difference of the total and
the paid


Answer: It looks like the data is being stored as strings. Have you tried changing
them to integers? You would do it like this. Suppose we have:

    
    
    x="1"
    
    y="2"
    

You can convert them to integers like this.

    
    
    x=int(x)
    
    y=int(x)
    

Then you should have no problem adding them.

