One line if else statement refuses to work

By Miguel Alberola Cano

Sorry for submitting a question this small but it’s driving me nuts. I have this single line which is permanently giving me syntax error:

print(BDF) if header is 1

I’ve also tried this:

print(BDF) if (header == 1)

Here’s the full function:

def CSVtoDict(BDF, prune, header):
    # Comes with the option to prune [] and to use headers
    with open('%s%s.csv' % (dataDir,BDF), mode='r') as infile:
        reader = csv.reader(infile)
        saved = {}
        for row in reader:
            key = row[0]
            saved[key] = [r for r in row[1:] if not (r is '' and prune is 1)]
        print(BDF) if header is 1
    return saved

What could possibly be causing this? I’m calling the function with:

adsMut = CSVtoDict(BaseDataFiles[0],1,1)

Everything seems to be in order, it just gives me syntax error every time.

Source: Stack Overflow


Share it with your friends!

    Fatal error: Uncaught Exception: 12: REST API is deprecated for versions v2.1 and higher (12) thrown in /home/content/19/9652219/html/wp-content/plugins/seo-facebook-comments/facebook/base_facebook.php on line 1273