I was wondering if there is a way to run the command line executable in python, but pass it the argument values ββfrom memory without writing the memory data to a temporary file on disk. From what I saw, it seems that subprocess.Popen (args) is the preferred way to run programs from within python scripts.
For example, I have a pdf file in memory. I want to convert it to text using the pdftotext command line function, which is present on most linux distributions. But I would prefer not to write the pdf file in memory to a temporary file on disk.
pdfInMemory = myPdfReader.read() convertedText = subprocess.<method>(['pdftotext', ??]) <- what is the value of ??
What is the method that I should name, and how should I transfer data to memory in my first input and output its output back to another variable in memory?
I guess there are other PDF modules that can do the in-memory conversion, and information about these modules would be helpful. But for future reference, I'm also interested in how to connect input and output to the command line from within python.
Any help would be greatly appreciated.
source share