D
D
denislysenko2021-10-07 15:35:23
Python
denislysenko, 2021-10-07 15:35:23

How to filter the table and output to the console?

I need to write a command line utility that will filter the table by movies, it has a lot of arguments, but all the arguments have already been processed, now I have a sorted data_movies table.

There is a data_movies table with 10,000 rows:
column values:
movie index, movie title, movie genres

this is what the table looks like:
data_movies = [
['3855', 'Affair of Love, An (Liaison pornographique, Une) (1999)', [ 'Drama', 'Romance']]
['4144', 'In the Mood For Love (Fa yeung nin wa) (2000)', ['Drama', 'Romance']]
['4235', "Amores Perros ( Love's a Bitch) (2000)", ['Drama', 'Thriller']]
['2589', 'Friends &
['2861', 'For Love of the Game (1999)', ['Comedy']]
['5450', 'Lovely & Amazing (2001)', ['Comedy', 'Drama', 'Romance']]
['3554', 'Love and Basketball (2000)', ['Drama', 'Romance']]
...
]

We need to write a command line utility that takes table filters as arguments.
Two arguments left to process

There are two arguments:
-N - the number of top rated films for each genre. optional
-genres - filter by genre, set by the user for example "Comedy". may be multiple. for example, "Comedy|Adventure" or "Comedy&Adventure". optional

if some arguments are not specified,
if nothing is specified at all, then all movies are displayed sorted by genre. the

output to the console should be like this:
If we write in the console:
program.py -N 3 -genres "Action&Adventure"
Then the result in the console:

gener, title, year
Action, xxx, xxx
Action, xxx, xxx
Action, xxx, xxx
Adventure, xxx, xxx
Adventure, xxx, xxx
Adventure, xxx, xxx xxx

- some data

filtered data_movies based on the -N and -genres arguments, and would return the final table result, the rows of which are the desired movies.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question