In Python there are simple one liners that can take a path like C:\\somefolder\\somesubfolder\\file.csv, grab the C:\\somefolder\\somesubfolder\\ part,
C:\\somefolder\\somesubfolder\\file.csv
C:\\somefolder\\somesubfolder\\