May-29-2019, 04:47 PM
(This post was last modified: May-29-2019, 04:48 PM by KINGLEBRON.)
y the data for movies with a rank above 9 for a new file.
The dataset that im analyze contains rating on many movies obtained from IMDB.
The data fields are:
Votes: the number of people rating the movie
Rank: the averate rating of the movie
Title: the name of the movie
Year: the year in which the movie was released
the code i tried is:
but unfortunately its not working, what should i do ?
The dataset that im analyze contains rating on many movies obtained from IMDB.
The data fields are:
Votes: the number of people rating the movie
Rank: the averate rating of the movie
Title: the name of the movie
Year: the year in which the movie was released
the code i tried is:
1 2 3 4 5 6 7 8 9 10 11 12 |
import csv filename = "IMDB.txt" with open (filename, 'rt' , encoding = 'utf-8-sig' ) 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 ): csv_writer.writerow( dict (current_row)) |
but unfortunately its not working, what should i do ?