python - how to get values in csv to a report

Trying to get a report from a csv file.

csv file: servers.csv

I'm trying to get a list of prod servers that contains the server name and zone.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Try ingesting data in your python script using this pipeline...

cat servers.csv | grep -v ^name | grep ",prod"

Open in new window

import csv

f = file('c:\users\mark\downloads\Q_29075243.csv')
for l in csv.reader(f):
    print l[0],l[2]

Open in new window

name zone
server1 dmz
server2 prod
server3 nonprod
server4 prod

Open in new window

LN41Author Commented:
Hi aikimark,Your answer is helpful but looking for a way to filter only for prod servers rather than manually id them. ideal result produces:

name zone
server2 prod
server4 prod
LN41Author Commented:
I think I got it. Thanks for the help.

import csv
with open('servers.csv', newline='') as f:
    reader = csv.reader(f)
    for row in reader:
        if row[3] == 'prod':

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LN41Author Commented:
figured it out myself
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.