It\'s need Pyhthon coding. Download the start.zip from blackboard. When you unzi
ID: 3597151 • Letter: I
Question
It's need Pyhthon coding.
Download the start.zip from blackboard. When you unzip it, you will see that there are many many folders where each folder has a name consisting of 8 lowercase letters or digests.
Write a program that analyzes the folder structure.
1) Find the path to the folders that have capital letters in their name.
2) Find the path to the 6 files that are inside the folders.
Note, please ignore files named ".DS_Store" in case you find one.
Remark: For full points, do NOT use os.walk.
#this function returns a set of file names
#including their paths, e.g.,
#start/38ask9sd/adsf928/saf828a/blub.lnk
def get_files():
return {}
#this function only returns the file names (without the path)
#it should use get_files() to create the return value
def get_file_names():
A = get_files()
return {}
#this function returns a set containing
#the full path to a capitalized folder
#start/38ask9sd/ADSF928/
def get_cap_folders():
return {}
# parses the folder structure and prints
# the paths to the files and upper case
# folders respectively
def parse_folder_structure(start='start'):
print("all upper case folder paths'")
print("all file paths'")
#if you implemented additional things, please
#copy below
Explanation / Answer
$fileData = fillArrayWithFileNodes( new DirectoryIterator( '/path/to/root/' ) );
function fillArrayWithFileNodes( DirectoryIterator $dir )
{
$data = array();
foreach ( $dir as $node )
{
if ( $node->isDir() && !$node->isDot() )
{
$data[$node->getFilename()] = fillArrayWithFileNodes( new DirectoryIterator( $node->getPathname() ) );
}
else if ( $node->isFile() )
{
$data[] = $node->getFilename();
}
}
return $data;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.