May-29-2019, 04:47 PM
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:
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 ?