C2_W1_Assigment. Autocorrect ! The input './data/shakespeare.txt' is empty

the input of the function process_data(file_name) ‘./data/shakespeare.txt’ is empty. so output is empty list. I downloaded the file and opened it to confirm that it is empty. Can anyone help me here please?

@Deepti_Prasad @paulinpaloalto @lucas.coutinho can anyone of you please help me here as this issue is not reported yet. so past thread might not be helpful here Thank you very much for your kind support

I just checked and that file is fine in my version of that assignment. Here’s what it looks like:

Somehow the file must be trashed in your file system. You can get a clean copy by deleting it and then using the “Get a Fresh Copy” logic described on this thread.

Please try that and let us know if it helps or not. If it doesn’t help the first time, that means you didn’t follow the instructions correctly. :nerd_face:

For the record, I deleted the file and got a fresh copy using that procedure and it worked fine and the new copy was also 307kB. I just wanted to be sure that there wasn’t something broken in the assignment.

hi @soumen2025

The reason of this output could be two reasons:

  1. by any chance you didn’t modify anything outside of the markers ###Start and end code here###??

Deleting any part of the header or argument can give such output.

  1. Another reason would be
    For code line open and read the content if you have used incorrect variable recall for the file, it should file_name as per argument.

Also as paul mentioned deleting and getting fresh copy would also be the work around in case you have modified anything in the file, or try deleting and clearing out kernel output, reconnect the kernel and re-run the cells from beginning one by one till you have the issue if you are confident of your codes being correct.

Regards
DP

Honestly neither did I change any ## stuffs nor did I use any incorrect variable. I wonder why the txt file size 0B. who can fix this? getting latest updated file doesn’t help me as the problem with text file not with the notebook. I don’t know who can fix this. Alternatively I have to copy the content from internet and paste there. @paulinpaloalto

I followed exactly what you mentioned and moreover I am familiar with this steps as I used for another course. Unfortunately I have not seen any changes in the text file ( empty content size 0 B). should I manually copy the content from internet to paste there or any other idea?

send the code screenshot of the grade function codes you wrote by personal DM.

Did you delete the file first? That was explicitly mentioned in the instructions. If you don’t delete it, it will not be replaced. The “get a clean copy” procedure specifically will not replace existing files. You must rename or delete the target file first.

If you can’t get the instructions to work, the alternative would be to “upload” the replacement copy you got from the internet. Although (by definition) that is not the official copy: the course files are not officially posted anywhere, so you must have found somebody’s illegal github copy. How do you know it’s really the same?

Also that copying from someone’s work is considered plagiarism and considered Violation of code of conduct, so just be careful about that too.

I mean to get the text file since I am unable to retrieve the text file. There is no point of copying other’s code as I don’t have issue with the code. Thanks for your reminder about plagiarism. anyways I am able to fix the issue by uploading the text file. That’s what I had to do.

It’s good that you found a solution, although you could have saved yourself the trouble by actually following the instructions I gave. You must not have actually deleted the file ./data/shakespeare.txt before doing the “get a fresh copy” procedure.

Also just to be 100% clear, anyone who posts any of the files from the courses on their public github account is violating the Terms of Use of the courses here. The information is for your personal use only and it is not legal to post it in a public way. Anyone who has a free github account is publishing whatever they upload there to the entire world.

Thank you very much for your constant support and follow-up. Surprisingly I followed exactly what you mentioned but surprisingly the text file didnt change anything. Yes I received the fresh notebook but not the text file. Somehow the content was removed from the text file. I appreciate both of you for kind support. @Deepti_Prasad

It’s not the notebook file you have to delete: it’s the file you want. Which in this case is ./data/shakespeare.txt. The “fresh copy” procedure deals with every folder and file in the assignment individually: it looks to see whether it is present. If it is present, it does not modify it. If it is missing, it gives you the latest version. It does not look at the contents of any of the files: it only cares whether each file is present or not.

That was explained in detail in the article that I sent at the beginning of this whole process.

@soumen2025

Did you refer to Paul’s tagged link?? click the highlighted blue description which will take you to step wise instruction on how to get a fresh copy in case you have deleted the file.

I also asked you to send screenshot of the grade function code process data for which you must have written the code, for us understand if there is any issue with the code.

please do the needful, and let us know if after getting fresh copy you still getting the same issue, they we need to check your code by personal DM.

hi @soumen2025

According to codes you just shared, the code line for

Convert every word to lower case and return them in a list.

needs correction.

Instructions given in exercise were
1.Look for the “Raw String Notation” section in the Python ‘re’ documentation to understand the difference between r’\W’, r’\W’ and ‘\W’.
2.For the pattern, decide between using ‘\s’, ‘\w’, ‘\s+’ or ‘\w+’.

although you did use the pattern and re module but the way used pattern was incorrect.

in the assignment if you checked re python documentation, it mentions

The solution is to use Python’s raw string notation for regular expression patterns; backslashes are not handled in any special way in a string literal prefixed with ‘r’.

so use the ‘r’ with the pattern you selected.

Regards
DP

Okay thanks for the pointer and fixed it.

so your issue is resolved right?