I'm extracting the first line that starts with 'abc' in a file
grep -w 'abc' --max-count=1 file.tsv
I wanna use it in a python program
import subprocess
process = subprocess.Popen("grep -w 'abc' --max-count=1 file.tsv",
shell=True,
stdout=subprocess.PIPE,
)
stdout = process.communicate()[0].split('\n')
My python is running on Windows
and grep
won't work. Is there an alternative that I can use in my python program.