-3

Hi can someone please tell me why i have an invalid syntax that appear in the last line exactly in the second " this is a script that iterates through the CSV file and converts everything to the decimal ASCII equivalent. Thank you

import csv
with open('C:\Users\user\Desktop\log_transformed_truncated.csv', 'w') as outfile:
c = csv.writer(outfile)
counter = 0
with open('C:\Users\user\Desktop\log.csv','rb') as f:
    for row in csv.reader(f, delimiter=';'):
        counter = counter + 1
        mod_row = []
        if counter != 1:
            for cell in row:
                mod_row.append(sum(bytearray(cell)))
        else:
            for cell in row:
                mod_row.append(cell)
        c.writerow(mod_row)
print "processed {} rows".format(counter)
Terry Jan Reedy
  • 18,414
  • 3
  • 40
  • 52
akagi sama
  • 23
  • 1
  • 4

1 Answers1

0

You forgot to put parentheses as it is the syntax for python 3.

This statement works for me:

print("processed {} rows".format(counter)) 

You can also review this answer for more information about the differences between the print statement in python 2 and python 3.

Omer Hen
  • 172
  • 1
  • 12
  • 2
    ...assuming questioner is using python 3. – tdelaney May 26 '18 at 14:28
  • 1
    If you run the line `print "processed {} rows".format(counter)` in a python 3 IDE you will get an expected syntax error at the second `"`, like the one the questioner referred to, making me believe he's using python 3. @tdelaney – Omer Hen May 26 '18 at 14:32