def process_data(infilename, outfilename):
    column_names = ('EXT', 'CHIP', 'X', 'Y', 'CHI_GL', 'SNR_GL', 'SHARP_GL',
        'ROUND_GL', 'MAJAX_GL', 'CROWD_GL', 'OBJ', 'COUNTS1', 'BG1', 'ACS1',
        'STD1', 'ERR1', 'CHI1', 'SNR1', 'SHARP1', 'ROUND1', 'CROWD1',
        'FWHM1', 'ELLIP1', 'PSFA1', 'PSFB1', 'PSFC1', 'FLAG1', 'COUNTS2',
        'BG2', 'ACS2', 'STD2', 'ERR2', 'CHI2', 'SNR2', 'SHARP2', 'ROUND2',
        'CROWD2', 'FWHM2', 'ELLIP2', 'PSFA2', 'PSFB2', 'PSFC2', 'FLAG2')
with open(infilename) as infile:
    with open(outfilename, 'w') as outfile:
        for line in infile:
            line = line.strip().split()
Optimized processing of very large files