I'm using the CSV module in python to read a CSV into memory and I need to skip the header row.
I am using the next command to skip the headers, but it isn't working.
import csv
with open(aws_env_list) as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
next(csv_reader)
The headers are still being produced, crashing my script. My script produces the following line:
Working in AWS Account: companyAccountName,AWSAccountName,Description,LOB,AWSAccountNumber,CIDRBlock,ConnectedtoMontvale,PeninsulaorIsland,URL,Owner,EngagementCode,CloudOpsAccessType
In the original CSV the headers are only on the first line.
The first few lines of my csv file look like this.
What's wrong with the above and why is this not skipping the headers? Is there a better way?
csv_reader = csv.reader(csv_file, delimiter='\t'). You wouldn't by any chance be typing this at the interactive prompt, would you?