1

When the output of this program is redirected into a csv file there is a blank line between the two lines of output.

The other solution I found on S.O involved changing the way that the output file is opened, but since I'm using stream redirection it doesn't seem to apply.

Could someone kindly suggest how I might be able to eliminate these extra spaces it would be greatly appreciated. Also please note that I am new to python and coding in general.

def output_data(aggregrate_objects):

    header = []
    results = []

    for object in aggregrate_objects:       #generate header
            header.append(object.name)

    for object in aggregrate_objects:       #generate results
            results.append(object.get_result())            


    writer = csv.writer(sys.stdout,dialect='excel',lineterminator=os.linesep)

    writer.writerow(header)        

    writer.writerow(results)

0 Answers0