I have a file with lines:
/home/Plugins/file1 e:222 k:dir (327/1)
/home/Plugins/file2 e:100 k:dir (326/1)
I want to take a path and element id. That's easy.
with open('output_file.txt', 'r') as output_file:
for line in output_file:
file_path = line.split()[0]
eId = line.split()[1].split(":")[1]
logging.info("file path:"+file_path)
logging.info("eId:"+eId)
But, the problem is that this Path of the file name (first element) itself can contain spaces - as folders OR files on the disk are created with blank space in their name (which is common case). So, I have these examples:
/home/tools/AMS Provider/file3.txt e:224 k:dir (127/1)
/home/account validator e:227 k:dir (247/1)
So path is always the first element but sometimes it contains spaces. My script above will fail because of these examples. In the given example:
AMS Provider (subfolder name)
account validator (file name at the end of the path)
Since, in this case, paths contain blank spaces (in the subfolder name but also in the file name at the end of the path) how I can still retrieve the path of the file. How to split it?
Note: unfortunately I am limited with python 2.7 on the server. Thanks!