Sometimes this is done for nefarious purposes; mining the internet for email add
ID: 3589654 • Letter: S
Question
Sometimes this is done for nefarious purposes; mining the internet for email addresses to be used in spamming, or worse. But it has many useful purposes. Text that represents ‘data,’ but not easily accessible ‘information.’ Getting information from data that isn’t in an accessible database format is a valuable skill.
In this exercise you will read a text file called ValenciaCourses.txt, and process each line with a RegEx.
Write into an output file the courses that have a lab component that is more than 3 hours. Here is an example of a class that has 2 credit hours, no classroom hours, and 6 lab hours:
CVT 1840L 2 0 6
This is an example of a course with 3 credit hours, 3 classroom hours and 0 lab hours
THE 2304 (Formerly THE 2300) 3 3 0
Your file will include all of the courses with more than 3 lab hours, and a count of the number of classes that have more than 3 hours of Lab. Post the courses that you found, and the number of them (not your code) on the discussion board in Blackboard. Include the courses and the number of courses that you found in your assignment submission.
Link to text file https://drive.google.com/file/d/0B0Om_q0Z84Bgc3dWNDhvUE5Jdkk/view?usp=sharing
Explanation / Answer
import re
count = 0
with open('Assignment6.txt') as fh, open('output-assignment6.txt', 'w') as fw:
for line in fh:
if re.match(r'^[A-Z]{3} d{4}([A-Z]?) d d [3456789]', line):
count += 1
fw.write(line)
print("Number of course found: %d" %count)
# code link: https://paste.ee/p/rkCEF
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.