i think the variables(target_id etc) are the reason why the codes look longer. if the codes can auto generate the variables will look shorter IMO
variables = 9 nestedlist = [[]]*variables #you have 9 variables(target_id... etc) so 9 lists in nestedlist generated. for line in target_file: if line.split()[0] != '#': splitted = line.split() for i in range(variables): nestedlist[i] = nestedlist[i] + [ splitted[i]] for index,variable in enumerate(nestedlist): print index,variablethe results stored in nestedlist, each index in printed result will correspond to variable (target_id,target_ra_deg) in order.