Reputation: 197
How do I parse a command line parameter and use it as a variable in the script to be used as filename to be saved as. I have tried the below but it is not working
fname:.z.X[2]
.....
...more code...
....
/Save the table into a csv file
`:(fname,".csv") 0:csv 0: table
Upvotes: 0
Views: 322
Reputation: 1697
You need to always remember the left of right evaluation.
In your case you are trying to write the csv delimited table to (fname,".csv"), which is only a string.
Further you want to use `$ to parse to a symbol (not `:), and use hsym to create a file path (prefix with ":")
bash> q script.q filename
q)(hsym `$ .z.x[0],".csv") 0:csv 0: ([]10?10)
`:filename.csv
Upvotes: 2