most of the solutions out there call awk from python. But i want to do it the other way round. I have a python script that extracts information from a file. However said filename is referenced in a column of the awk script.
How do i pass python the argument “%s20s”, filename and get the input from the standard output? i want to add the output as several columns more.
thanks for your examples
Cheers
The awk variable FILENAME gives the name of the current file being processed (or ‘-‘ if stdin). However, this is not available in the BEGIN block, but you can use ARGV[1] instead (assuming you are only passing one filename):
The python script (py3) I used for testing was:
So I get the following output: