Skip to content

Instantly share code, notes, and snippets.

@Prajwalprakash3722
Created September 14, 2023 20:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Prajwalprakash3722/d8ebd5fa32f0cea84bd51ea7685d9e83 to your computer and use it in GitHub Desktop.
Save Prajwalprakash3722/d8ebd5fa32f0cea84bd51ea7685d9e83 to your computer and use it in GitHub Desktop.
Count the number of Series & Movies you have watched, Download the NetflixViewingHistory from your account/profile
package main
import (
"encoding/csv"
"fmt"
"os"
"regexp"
)
func main() {
file, err := os.Open("NetflixViewingHistory.csv")
if err != nil {
fmt.Println("Error opening CSV file:", err)
return
}
fmt.Println("Successfully opened CSV file")
defer file.Close()
reader := csv.NewReader(file)
seriesCount := 0
regex := regexp.MustCompile(`^([^:]+):`)
seriesMap := make(map[string]bool)
for {
record, err := reader.Read()
if err != nil {
break
}
title := record[0]
matches := regex.FindStringSubmatch(title)
if len(matches) > 1 {
seriesName := matches[1]
seriesMap[seriesName] = true
}
}
seriesCount = len(seriesMap)
fmt.Printf("Total movies/series watched: %d\n", seriesCount)
fmt.Println("Series watched:")
for seriesName := range seriesMap {
fmt.Println(seriesName)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment