Skip to content

Instantly share code, notes, and snippets.

@alimbada
Last active April 8, 2025 12:22
Show Gist options
  • Save alimbada/4b9b3778d92f260cf289f1b2aa942aa8 to your computer and use it in GitHub Desktop.
Save alimbada/4b9b3778d92f260cf289f1b2aa942aa8 to your computer and use it in GitHub Desktop.
Analyse Netflix viewing activity by profile

This script allows you to analyse the ViewingActivity.csv file included in your Netflix data and outputs a list of shows watched by a particular profile ordered by frequency (i.e. number of times viewed and number of episodes viewed).

Usage

You will first need to request your Netflix data, download it and extract the zip file. You can do this by going to Account -> Security -> Personal information access

You will also need to install xsv or a similar tool.

Adjust the grep and awk expressions as appropriate. The grep expression will exclude lines where those strings are found (e.g. exclude teasers/trailers). The awk expression is necessary for specifying a cutoff for the show title to allow grouping of shows, e.g. Stranger Things: Stranger Things 2: Chapter One: MADMAX (Episode 1) will be transformed to Stranger Things to allow accurate counting of each shows views.

ℹ️ Hint: If you want to see the number of unique titles viewed rather than the number of times a show/title was viewed, replace the first sort with sort -u. The default behaviour can be useful for analysing viewing habits of profiles where titles are viewed multiple times (e.g. children's profiles) but this may not be useful for many others. The default behaviour is also inaccurate as Netflix counts even viewing something for as little as 1 second as a view.

grep PROFILE_NAME CONTENT_INTERACTION/ViewingActivity.csv | grep -Eiv "Trailer|Teaser|Clip" | xsv select 5 | tr -d '"' | sort | awk -F': Season|: Book|: Part|: Volume|: Limited|: Series|: Stranger' '{ print $1 }' | uniq -c | sort -nr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment