Day 56 - os.path usage

The solution makes use of os.path to write the songs to each artist folder but this method hasn’t been sufficiently covered in the tutorials to be understandable to students. Can someone provide a good explainer on how this is working and how we should know when to utilize this technique?

import csv, os

with open("100MostStreamedSongs.csv") as file:
  reader = csv.DictReader(file)
  
  for row in reader:
    dir = os.listdir()
    artist = row["Artist(s)"].title()
    print(artist)
    if artist not in dir:
      os.mkdir(artist)
    song = row["Song"]
    print(row["Song"])
    path = os.path.join(f"{artist}/", song)
    f = open(path, "w")
    f.close()

A post was merged into an existing topic: Day 056 - Project 56 : Sorting Songs by Artist