I am trying to open a CSV file in python and count occurrences of a certain phrase. I believe I have written the correct code but every time I keep tryin to open it tells me that it cannot find the file. Am I importing the file incorrectly or is something else The fil b

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

please answer within 30 minutes.

I am trying to open a CSV file in python and count the
occurrences of a certain phrase. I believe I have
written the correct code but every time I keep trying
to open it tells me that it cannot find the file. Am I
importing the file incorrectly or is something else
wrong? The file name has been spelled correctly.
# Question #4
# In the clickstream data, how many times has the page "Star Trek IV The Voyage Home"
it been referenced? (What is the total amount of the occurences column?)
#
# Write code to open the file, read the individual lines and total up the
# number of occurences and print out the total.
#
#Place all of your code inside the cell definition below
#%% question 4 response here
word "Star Trek TV The Voyage Home"
count 8
with open("ClickStreum.csv", 'r') as f:
for line in f:
words = line.split()
for i in words:
if(i==word):
count-count+1
print("Occurrences of the word", word, ":", count)
Come / X
words line.split()
for i in words:
if(i--word):
Help Variable Explorer Plots les
count-count+1
...: print("Occurrences of the word", word, ":", count)
Traceback (most recent call last):
File "C:\Users\kylec\AppData\Local\Temp/ipykernel_12560/1947528635.py", line 3, in <module>
with open("ClickStream", 'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'ClickStream'
Transcribed Image Text:I am trying to open a CSV file in python and count the occurrences of a certain phrase. I believe I have written the correct code but every time I keep trying to open it tells me that it cannot find the file. Am I importing the file incorrectly or is something else wrong? The file name has been spelled correctly. # Question #4 # In the clickstream data, how many times has the page "Star Trek IV The Voyage Home" it been referenced? (What is the total amount of the occurences column?) # # Write code to open the file, read the individual lines and total up the # number of occurences and print out the total. # #Place all of your code inside the cell definition below #%% question 4 response here word "Star Trek TV The Voyage Home" count 8 with open("ClickStreum.csv", 'r') as f: for line in f: words = line.split() for i in words: if(i==word): count-count+1 print("Occurrences of the word", word, ":", count) Come / X words line.split() for i in words: if(i--word): Help Variable Explorer Plots les count-count+1 ...: print("Occurrences of the word", word, ":", count) Traceback (most recent call last): File "C:\Users\kylec\AppData\Local\Temp/ipykernel_12560/1947528635.py", line 3, in <module> with open("ClickStream", 'r') as f: FileNotFoundError: [Errno 2] No such file or directory: 'ClickStream'
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY