Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. from pathlib import Path
  2. import sys
  3. import pprint
  4.  
  5.  
  6. def get_directories(path):
  7.     # Get the subdirectories from that desired path
  8.     sub_dirs = list(Path(path).glob('*/'))
  9.     # Here we store the results
  10.     results = []
  11.     for sub_dir in sub_dirs:
  12.         dir_name = sub_dir.as_posix()
  13.         file_check = dir_name + '/CS' + sub_dir.stem + '.csv'
  14.  
  15.         # We are omitting the files that match the check and adding the others:
  16.         if not Path(file_check).is_file():
  17.             results.append(dir_name)
  18.  
  19.     return results
  20.    
  21. if __name__ == '__main__':
  22.     path = sys.argv[1]  # This is the first argument, argv[0] is the name of the script
  23.     # To be simple, just lets print these out
  24.     pprint.pprint(get_directories(path=path))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement