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 to download.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter3: Input/output
Section: Chapter Questions
Problem 12SA: 12. What is the output of the following program? (2, 3, 6, 8) #include <iostream> #include...
icon
Related questions
Question

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 to download.

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 to download.
465192.3297196.qx3zqy7
Transcribed Image Text: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 to download. 465192.3297196.qx3zqy7
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning