0

Just wondering what's triggering this syntax error:

  File "/Users/samuelfinegold/Documents/noodle/add_col.py", line 16

                                                 ^
SyntaxError: invalid syntax
logout

[Process completed]

Script:

import csv

# fieldnames = ['name','degrees','area','phone','email','website']

with open('ieca_first_col_fake_text.txt', 'r') as input:
    with open('new_col.txt', 'w') as output:
        writer = csv.writer(output)
        for row in csv.reader(input):
            writer.writerow(row+['Berry'])
            writer.writerow(row.append('new_col')

# with open('ieca_first_col_fake_text.txt','r') as input:
#     with open('new_col_dict.txt','w') as output:
#         dict_writer = csv.DictWriter(output, fieldnames, delimiter = '\t')
#         dict_reader = csv.DictReader(input)

Thanks!

3
  • And, what is line 16? Commented Jul 8, 2013 at 14:34
  • That is a good question...guessing they think it's the next row that the comp thinks I've enter by not closing the parenthesis Commented Jul 8, 2013 at 14:36
  • oic. Syntax errors at end of file are usually caused by missing close brace or close parenthesis. Commented Jul 8, 2013 at 14:38

1 Answer 1

3

You missed a closing ) on this line:

writer.writerow(row.append('new_col')
                                     ^         
                                     | 
Sign up to request clarification or add additional context in comments.

1 Comment

Any chance you know how to add a column that's tab separated? stackoverflow.com/questions/17528274/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.