I'd like to create a Python script that I can pipe file names into, so it can be used like this:
ls *.csv | python .\myscript.py
I know I can read the standard input using fileinput
or sys.stdin
, but since the output is in a formatted table:
Directory: C:\path\to\csv
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 15.02.2016 10:18 4755 data_1.csv
-a---- 15.02.2016 10:18 522 data_2.csv
I'd have to parse it.
Since this seems to be a common pattern, I expect there's a standard solution. I'd like to avoid writing my own if I can, but I haven't been able to find any.
(In case it's important, I'm running it in PowerShell on Windows 10.)
Edit: I'm asking whether there's some library or pattern I'm missing, for this specific (and seemingly quite common) scenario of piping file paths to a script. I'd like to avoid writing parsing code if it isn't necessary.