Function that can search through all files in two directories

I’m working on a Python exercise and need support.

Hello πŸ™‚

I need some help writing a function that can extract the address cities from two directories. The input is an ‘ID’ (file name without the .txt). Function will search through the entire directory and find the file with matching name. Matching file will be opened and searched with regex (re.search) to extract the address (cities) as return value.

Folder directory map:

searchAddress_x000D_
β”œβ”€β”€ group1_x000D_
β”‚   β”œβ”€β”€ A01.txt_x000D_
β”‚   β”œβ”€β”€ A02.txt_x000D_
β”‚   _x000D_
└── group2_x000D_
    β”œβ”€β”€ B01.txt_x000D_
    └── B02.txt

ID_input = B01

searchAddress (ID_input):

“function first check to see if B01 is a valid file name in all folder. Proceed to the open the fileB01.txt if file name is valid and extract the address (city information)

address line format like this:

Address. new york| tokyo| LA | SF

extract all the city names and count how many names in the address row

return two values. Count of cities in the address

List of cities

1. new york

2. tokyo

3. LA

4. SF





"Looking for a Similar Assignment? Order now and Get a Discount!

Posted in Uncategorized