Day 056 - Project 56 : Sorting Songs by Artist

If you have any questions, comments or issues with this project please post them here!

Hey guys,

just wondering, is there a “trash” function in Replit, or a way to restore an accidentally deleted file? I’ve deleted the csv file of Day 56 and now I can’t continue with the challenge. I’m pretty sure I was close to the final assignment, but I can’t verify my progresses without that file.

Thanks!

I do not believe so, hence the message warning you that deleting a file is irreversible. However if you try creating a new file with exactly the same name, sometimes the original file wasn’t actually deleted yet and you can restore its contents like that. Otherwise, you could try your Repl’s history, but if you deleted the file I don’t know that it would show up there.

3 Likes

Hi deedend. Did you find a solution?
I now tested that at least deleting a repl should work to restart the exercise.
I started my current day, added things there, then closed it and deleted it from my history (repls in my profile page.
Then I went back to 100 page and it didn’t show “continue”, but “restart”.
It was a fresh repl in this case.
(I didn’t dare to delete the ready given files, but I expect it would work as well)

Hey @deedend,

I’ve tried this and it works for me :

  1. Go to your repl
  2. Create the same file you deleted with the same name
  3. You should see the content on it

It works for me! If it doesn’t work, I suggest you do a feature request on #feature-requests!

2 Likes

Thanks, guys,

I’ve solved it in a pretty brutal way… I created a new account and fasted forward all the lessons until I arrived on the same day, downloaded the CSV file on my computer then copied it back on replit. But next time, if something similar happens I will keep in mind the tricks you suggested.

Many thanks again!

1 Like

Hi, Im having trouble with my day 56 code, and I don’t know how to solve it. I literally copied the answer line by line and it is always poping up:

Traceback (most recent call last):
  File "main.py", line 4, in <module>
    reader = csv.Dictreader(file)
AttributeError: module 'csv' has no attribute 'Dictreader'

Anyone help?

I believe that you have a typo, capitalization of dictreader
try with csv.DictReader(file)

I have managed to solve it pretty much by myself but I am a bit enraged with how the challenge asks for one thing and then the solution gives a different answer. Specifically it stated make a TXT file with song title and then the solution makes a subfolder instead of txt file. And as days go by more and more of these inconsistencies appear in lessons… :confused:

Thank you for highlighting this @Thrsh001 . I’ll pass the feedback along so it can be looked into and updated.

I strictly used help of chatgpt for only syntax and understanding how I can use the concepts I have already learnt so fat until day 56

import os, csv

with open("100MostStreamedSongs.csv") as file:
    reader = csv.DictReader(file)

    for row in reader:
      songname = ''.join(row["Song"].split())
      special_characters = ['!', '"', '#', '$', '%', '&', "'", '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '`', '{', '|', '}', '~', '”']
      for character in special_characters:
        songname = songname.replace(character, '').lower()
      
      artistname = ''.join(row["Artist(s)"].split())
      special_characters = ['!', '"', '#', '$', '%', '&', "'", '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '`', '{', '|', '}', '~', '”']
      for character in special_characters:
        artistname = artistname.replace(character, '').lower()
    
      try:
        os.mkdir(artistname)
      except:
        pass
        
      filename = os.path.join(f"{artistname}/", f"{songname}.txt")
      f = open(filename, "w")
      f.close()
1 Like

I mean it looks like your code works, but you are doing stuff really inefficiently. I suggest you look at the official replit solution so you can get an idea of what’s needed.

2 Likes

i was trying to use some code to make the folders and i succeeded but i ran the code twice so i tried to delete the folders and accidentally deleted all the files so i do not have the main.py, tutorial, or the necessary packages is there any way to restart the whole day and start from the beginning?

Hi there @IanAtCSTeach , I am also unsure of what the point of many of these tutorials is.

Are you aware that the CSV file used for day 56 has a song name with a comma in it? What would be your solution to downloading a CSV file that used a comma both as a delimiter and inside of entries?

How would you even check for that?

Hi @EmeraldMoss Day 56 is a project that allows you to apply your knowledge of CSV file wrangling.

Can you give more details about the song that has a comma in the title, because I can’t find it.

1 Like

My knowledge of CSV wrangling produced an anomaly, and apparently the Replit Staff aren’t aware of it, so what is the point of manipulating CSV files?

(Thank U, Next by Ariana grande.

My program produces a folder called 1.586 (or something like that) because the DictReader function assumes that the word “Next” applies to the play count and the Play Count becomes the Artist.

If your replit did not produce this folder, then your csv file or your python code must be significantly different from mine.)

Hi @EmeraldMoss , thank you for confirming. My method of searching the CSV file for commas yesterday wasn’t good enough to spot that one at line 68. Much appreciated for pointing that out.

I’ll pass this back to @DavidAtReplit and see if we can get this fixed sharpish.

3 Likes

Fixed! Thanks for pointing it out

2 Likes

I don’t understand the logic behind using if artist not in dir:
Isn’t it not supposed to create artist files because they are present in os.listdir() ?

Hey @ApoorvGoyal2!

It wants to check if isn’t there to create the artist files. It shows the user about dir’s and if something is in something else. I hope this answers your question.

1 Like