Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

12.9 LAB: Word frequencies (lists) Write a program that first reads in the name of an input file and then reads the file using the

12.9 LAB: Word frequencies (lists)

Write a program that first reads in the name of an input file and then reads the file using the csv.reader() method. The file contains a list of words separated by commas. The program must output the words and their frequencies (the number of times each word appears in the file) without any duplicates.

Ex: If the input is:

input1.csv

and the contents of input1.csv are:

hello,cat,man,hey,dog,boy,Hello,man,cat,woman,dog,Cat,hey,boy

the output is:

hello - 1 cat - 2 man - 2 hey - 2 dog - 2 boy - 2 Hello - 1 woman - 1 Cat - 1 Notes: Output words in order of first occurrence in input and end output with a newline. File input1.csv is available hello,cat,man,hey,dog,boy,Hello,man,cat,woman,dog,Cat,hey,boy

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions