Record#
- Today there is no knowledge point to learn, only coding practice.
- Write a super comprehensive program to read and write music information locally.
- Today's programming went relatively smoothly, except for mistaking csv.DictReader and csv.Reader. Only DictReader reads in dictionary format.
CODE#
import csv, os
print("artist")
with open("100MostStreamedSongs.csv", "r") as file:
reader = csv.DictReader(file)
folder = os.listdir()
for row in reader:
if row['Artist(s)'] not in folder:
os.mkdir(row['Artist(s)'])
pathname = f"{row['Artist(s)']}/{row['Song']}.txt"
with open(pathname, "w") as f:
f.write(pathname)
print("done!")
Translation: