I'm not clear what you mean by 'piped' commands, but I think there are three key elements to a solution:
In Python, files are 'iterable', which means that you can use an open (text) file on the right hand side of a for loop, and it will iterate over the files' lines:
for line in open('songs.txt'):
Splitting the left and right side of a line can be done using the
partition
method of string objects:left, sep, right = line.partition('&&&&&&')
Note that the 'right' element will contain the line ending character(s), and both
left
andright
may contain additional whitespace. You probably want to remove all this withstrip
.left = left.strip() right = right.strip()
Actually running commands should probably be done with subprocess, which can handle blocking calls (using
call
orcheck_call
) or running commands in the background with pipes attached usingPopen
. Note that all these commands want a list of arguments rather than just a command line string - the subprocess docs should help here.