Question: In this assignment you will be writing a script that will read in the words.txt file as a command line argument and perform the following
In this assignment you will be writing a script that will read in the words.txt file as a command line argument and perform the following actions 1-5. (Use the File3.tar.gz file)
Remove all words that have a dash (‘-’) or a number (0-9) or a comma (‘,’) or an ampersand (&).
Convert all uppercase to lowercase
Write this file out and name it words_clean.txt. This file should be created in the same directory as you run the script!
Loop through words_clean and separate out all of the words into files named a.txt, b.txt … etc. The a.txt file should have all the letters starting with ‘a’ … all the way to z.txt that should have all the letters starting with z. These files should be created in the same directory as you run the script!
Loop through all of the a.txt, b.txt etc and create a stat file for each that lists th # overall words in that file. Each file should be named a.txt.stat, b.txt.stat … and so on… These files should be created in the same directory as you run the script!
File3.tar.gz file:
s.txt.stats
o.txt.stats
statsOut.txt
i.txt
n.txt.stats
t.txt
g.txt.stats
c.txt.stats
a.txt
e.txt
a.txt.stats
h.txt.stats
temp2.txt
k.txt.stats
o.txt
x.txt.stats
Step by Step Solution
3.47 Rating (160 Votes )
There are 3 Steps involved in it
import sys Input filename that you want to read Samplefile sysargv1 Open the file in read mode fold openSamplefile r printfoldread Function to check i... View full answer
Get step-by-step solutions from verified subject matter experts
