Question
We are using the following dataset(there are total of 4.4M tweets in this file, but you only need to read 1M): http://rasinsrv07.cstcis.cti.depaul.edu/CSC455/OneDayOfTweets.txt Write a python
We are using the following dataset(there are total of 4.4M tweets in this file, but you only need to read 1M): http://rasinsrv07.cstcis.cti.depaul.edu/CSC455/OneDayOfTweets.txt
Write a python coded that will download the adove link's data and save to a local text file. ONLY needs to read 1,000,000 lines worth of tweets.
We cant use: read() or readlines() without any parameters at any point. That command will attempt to read the entire file which is too much data.
This is want I have so far:
import time import urllib.request
Start = time.time()
webFD=urllib.request.urlopen("http://rasinsrv07.cstcis.cti.depaul.edu/CSC455/OneDayOfTweets.txt")
New_file = open('downloadedfile.txt','w')
Line = webFD.readline() - I can use that so what do I need to do instead
tweetsdata= (Line.decode('utf8')).split('EndOfTweet') for L in range(100000): New_file.write(L +' ')
New_file.close()
End=time.time()
print("difference is", (End-Start), "seconds") print("performance:", 100000/(End-Start), "operation per second") print("new file for tweetdata is on the desk top")
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started