Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. in_file = 'dados_limpos_2018.csv'
  2. out_file = 'dados_2018.csv'
  3. output = open(out_file, 'w')
  4. with open(in_file, 'r') as source:
  5. for line in source:
  6. # split by semicolon
  7. data = line.strip().split(';')
  8. # remove all quotes found
  9. data = [t.replace('"','') for t in data]
  10. for item in data[:-1]:
  11. item.replace(',', '')
  12. output.write(''.join(['', item, '',',']))
  13. # write the last item separately, without the trailing ';'
  14. output.write(''.join(['"', item, '"']))
  15. output.write('n')
  16. output.close()
  17.  
  18. name, number, sgUF, txtDescricao, year
  19. Romario, 15, RJ, Consultoria, 2018
  20. Ronaldo, 9, RJ, Logistics, Search and Support, 2018
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement