Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python csv
#7
(May-29-2019, 05:49 PM)heiner55 Wrote: I add: errors=replace: (https://docs.python.org/3/library/functions.html#open)

#!/usr/bin/python3
import csv

filename = "IMDB.txt"
with open(filename, 'rt', encoding='utf-8-sig', errors='replace') as imdb_file:
   imdb_reader = csv.DictReader(imdb_file, delimiter = '\t')

   with open('new file.csv', 'w', newline='') as high_rank:
       fieldnames = ['Votes', 'Rank', 'Title', 'Year']
       writer = csv.DictWriter(high_rank, fieldnames=fieldnames)
       writer.writeheader()

       for line_number, current_row in enumerate (imdb_reader):
           if(float(current_row['Rank']) > 9.0):
               writer.writerow(dict(current_row))

i didn't understand what should i do with this error?
thanks for your help!
Reply


Messages In This Thread
python csv - by KINGLEBRON - May-29-2019, 04:47 PM
RE: python csv - by heiner55 - May-29-2019, 04:50 PM
RE: python csv - by KINGLEBRON - May-29-2019, 04:59 PM
RE: python csv - by heiner55 - May-29-2019, 05:25 PM
RE: python csv - by KINGLEBRON - May-29-2019, 05:40 PM
RE: python csv - by heiner55 - May-29-2019, 05:49 PM
RE: python csv - by KINGLEBRON - May-29-2019, 05:59 PM
RE: python csv - by heiner55 - May-29-2019, 06:02 PM
RE: python csv - by KINGLEBRON - May-29-2019, 06:16 PM
RE: python csv - by heiner55 - May-29-2019, 06:46 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020