0

I have a code where in I first convert a .csv file into multiple lists and then I have to create a subset of the original file containing only those with a particular word in column 5 of my file.

I am trying to use the following code to do so, but it gives me a syntax error for the if statement. Can anyone tell me how to fix this?

import csv
with open('/Users/jadhav/Documents/Hubble files/m4_hubble_1.csv') as f:
    bl = [[],[],[],[],[]]
    reader = csv.reader(f)
    for r in reader:
        for c in range(5):
            bl[c].append(r[c])

    print "The files have now been sorted into lists"
    name = 'HST_10775_64_ACS_WFC_F814W_F606W'
    for c in xrange(0,1):
        if bl[4][c]!='HST_10775_64_ACS_WFC_F814W_F606W' 
            print bl[0][c] 
1
  • Hint: you are missing a : character.. Commented Jul 2, 2012 at 15:00

1 Answer 1

2

You need a colon after your if test, and you need to indent the if taken clause:

if bl[4][c]!='HST_10775_64_ACS_WFC_F814W_F606W':
    print bl[0][c] 
Sign up to request clarification or add additional context in comments.

1 Comment

Indentation problems on SO are usually caused by the poster not knowing how to format code blocks.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.