[Solved] Python elif: syntax error


you end the if block in the previous line when put a instruction at the same level indentation that the if statement

if condition:
    stuff
something # doing this close the if block

and a elif can only happen in a if block

and you do that in

    if row_count == 0:
        for i in new_list:
            da_appendere = i
            reportwriter.writerow(da_appendere)
    csvfile.close() #<-- here you close the if block

#controllo ultimo timestamp    
    elif:    #<-- you forgot the condition, and is outside of a 'if' block 
        with open(nomen, 'rb') as f:
            last_timestamp = f.readlines()[-1].split(",")[0]

futhermore you forget to put a condition in the elif, if you don’t need one use else instead

2

solved Python elif: syntax error