二手产品经理

二手产品经理

THIS IS RENO

Code Practice - 56 Days - Learn Python Online in 100 Days

Record#

  1. Today there is no knowledge point to learn, only coding practice.
  2. Write a super comprehensive program to read and write music information locally.
  3. Today's programming went relatively smoothly, except for mixing up csv.DictReader and csv.Reader. Only DictReader reads in dictionary form.

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!")


Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.