Trying to access folders in a sharedrive

41 views Asked by At

I am trying to access folders in a sharedrive but the numbers placed in front of the folder names are causing issues. I have no idea why the numbers in front of the two folders 02_COLLECTION_VEHICLES and 07_GIS_LAYERS are present. I created the GIS_LAYERS folder but I didn't name it along with the 07_. At any rate, my program can access the sharedrive folders just fine that do not have the numbers and underscores in their name. So what can I do to access these folders? I was thinking of using regular expressions but im not sure how to use them in this case.

Here is the code for accessing and retrieving the file:

def readerOut():
    import os
    import re
    os.chdir(\
    ('S:\PAVE_MANAGEMENT\AUTOMATED_DISTRESS_SURVEYS\02_COLLECTION_VEHICLES\07_GIS_LAYERS')
    reader = open('2015_FILES_COMBINED.CSV')
    yield reader

When I run this code I get a WindowsError: [Error 3] and it says that it cannot find that specified file path.

Would something like this work if it was in the function?:

re.search('^[0-9]\\d*_COLLECTION_VEHICLES\^[0-9]\d*_GIS_LAYERS')
2

There are 2 answers

0
Thothadri Rajesh On BEST ANSWER

Use multiple back slashes instead of single back slash and then give a try

0
AudioBubble On

Here is the answer to this question. Using four slashes in front of each of the folders in question allows me to access those folders. Also, when I enter the fourth slash, a drop down menu in IDLE allows me a choose which folder I want to access. Thanks to https://stackoverflow.com/users/998217/thothadri-rajesh

os.chdir('S:\PAVE_MANAGEMENT\AUTOMATED_DISTRESS_SURVEYS\\\\02_COLLECTION_VEHICLES\\\\0‌​7_GIS_LAYERS')