from __future__ import print_function ''' Week Two Assignment 2 - File Hashing ''' ''' Complete the script below to do the following: 1) Add your name, date, assignment number to the top of this...

from __future__ import print_function
'''
Week Two Assignment 2 - File Hashing
'''
'''
Complete the script below to do the following:
1) Add your name, date, assignment number to the top of this script
2) Using the os library and the os.walk() method

a) Create a list of all files
b) Create an empty dictionary named fileHashes

c) Iterate through the list of files and
- calculate the md5 hash of each file
- create a dictionary entry where:
key = md5 hash
value = filepath
d) Tterate through the dictionary
- print out each key, value pair
3) Submit
NamingConvention: lastNameFirstInitial_Assignment_.ext
for example: hosmerC_WK1_script.py
hosmerC_WK1_screenshot.jpg
A) Screenshot of the results in WingIDE
B) Your Script
'''
import os
import hashlib
directory = "."
fileList = os.walk('.')
fileHashes = {}
for root, dirs, files in os.walk(directory):
# Walk the path from top to bottom.
# For each file obtain the filename

for fileName in files:
path = os.path.join(root, fileName)
fullPath = os.path.abspath(path)
fileHashes[eachFile] = absPath
for key, value in fileHashes.items():
print(key, value)



from __future__ import print_function ''' Week Two Assignment 1 - File Processing ''' ''' Complete the script below to do the following: 1) Add your name, date, assignment number to the top of this script 2) Open the file redhat.txt a) Iterate through each line of the file b) Split eachline into individual fields (hint str.split() method) c) Examine each field of the resulting field list d) If the word "worm" appears in the field then add the worm name to the set of worms e) Once you have processed all the lines in the file sort the set iterate through the set of worm names print each unqiue worm name 3) Submit NamingConvention: lastNameFirstInitial_Assignment_.ext for example: hosmerC_WK2-1_script.py hosmerC_WK2-2_screenshot.jpg A) Screenshot of the results in WingIDE B) Your Script ''' import os uniqueWorms = set() with open("redhat.txt", 'r') as logFile: for eachLine in logFile: ''' your code starts here '''
Sep 04, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here