Honors 1000, Productive Data Manipulation in Python and SQL (Fall 2018)

Assignment 3 - Count letters (Due: Wednesday, October 17, 2018)

Write a Python program to count number of occurrences of the alphabetical letters in a text file. Here are couple of text files for you to test your program against:

lipogram

hob

Write the following two functions:

import sys

def getCounts(fname):
# this function takes the name of a file as input parameter, fname
# it then reads the file into a string variable
# then proceeds to process the string for the count of letters
# answer should be returned in a list of 26 numbers

def main():
# this function calls the getCounts function with sys.argv[1], the name
# of the file provided by the user on command line
# then prints the answer

NOTES:

sys is a Python library that allows us to extract command line parameters

the Python commands to read from file is:

  with open(fname, "rb") as f:
    data = f.read().decode(“ANSI”)