Pweave
Pweave copied to clipboard
Pass argument to the script
Is there a way how to pass command line arguments to the script?
pweave --help should provide some answers, otherwise you should explain what script you are talking about.
The idea is that i have Pweave document (script), which generates report, now I would like to generate same report for different input data, ideally without the need to change the document itself, so is there a way how to pass parameters when I'm generating the report:
$ pweave FIR_design.pmd data.csv
Maybe something like: $ pweave script.texw --args 'data.csv'
?
Yes that would be great.
Nice idea! A few comments.
- This seems related to parametrized reports in R. I think we should take a look at that design and see what we can learn.
- This looks like a major feature to me. We may have to wait for creator @mpastell to have a bit more time availability.
- What about workarounds. What if your pweave doc just opened a file named "data.csv"? Is that clearly inferior?
- What about workarounds. What if your pweave doc just opened a file named "data.csv"? Is that clearly inferior?
I use 'config.ini' to pass necessary arguments (including filenames) to my scripts, but there is still a problem that I need to edit it every time I want to weave with different parameters.
How about something like:
$ echo 'data.csv' > .config.txt; pweave script.texw
with script.texw looking like that:
<<>>=
argv = open('.config.txt').readlines()
@
I would like to add my vote for this feature as well. I would prefer the simplicity of @abukaj's suggestion over something like how parameterized reports works in R. Right now I have a variable inside the script that I change for different datasets but is inelegant and clunky. I'm considering creating a wrapper function to first create the file as suggested with supplied arguments.