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)

  1. Remove all words that have a dash (‘-’) or a number (0-9) or a comma (‘,’) or an ampersand (&).

  2. Convert all uppercase to lowercase

  3. Write this file out and name it words_clean.txt. This file should be created in the same directory as you run the script!

  4. 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!

  5. 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

1 Expert Approved Answer
Step: 1 Unlock

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

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!