Syntax error while reading CSV file

Asked

Viewed 88 times

-3

I am trying, from a csv table, to remove certain information that is not useful to me, but in the code there is an error, according to python 3, but I can not notice the error.

The error is on line 08, (file = open('salicapiprojetos02.csv', encoding = 'utf8')), with the following message: Syntaxerror: invalid syntax

Follows the code

import csv
import pandas as pd


arquivo_wri = open('projeto_dira.csv', mode='w', encoding = 'utf8')
arquivo_projeto = csv.writer(arquivo_wri, lineterminator = '\n')
arquivo_projeto.writerow(['nome', 'valor_captado', 'segmento', 'area']        

**arquivo = open('salicapiprojetos02.csv', encoding = 'utf8')**
for registro in csv.DictReader(arquivo):
                         int(registro)
                         if registro['valor_captado'] != 0:
                             nome = registro['nome']
                             valor_captado = registro['valor_captado']
                             segmento = registro['segmento']
                             area = registro['area']
                             arquivo_projeto.writerow([nome, valor_captado, segmento, area])

arquivo_wri.close()
  • The parentheses of the writerow of the previous line?

  • Yes, Lucas! A mistake of mine! Thank you very much!

1 answer

1

Hello!!

The problem is in this line actually:

arquivo_projeto.writerow(['nome', 'valor_captado', 'segmento', 'area']        

is missing close the ")".

  • 1

    Really, Karen. Since I’m "green," I didn’t even notice. Thank you very much! Really! ^^

Browser other questions tagged

You are not signed in. Login or sign up in order to post.