简体   繁体   中英

I want to remove the header from my csv writer (the output file)

I want to remove the header from my csv writer (the output file). Not sure what to do. Below is my code:

def WriteToCSV(OutPutFile, dataOut):
    global logger

    try:
        with open(OutPutFile, 'w', newline='') as csvfile:
            writer = csv.writer(csvfile, delimiter='|', quotechar='"', quoting=csv.QUOTE_ALL)

            for data in dataOut :
                writer.writerow(data)

You're passing in a list of output data. The 1st element is the CSV column headings. Simply elide it:

            for data in dataOut[1:]:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM