0

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
Thomas Smyth - Treliant
  • 4,993
  • 6
  • 25
  • 36
Alim Hasanov
  • 197
  • 1
  • 3
  • 16

1 Answers1

2

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
Sean O'Hagan
  • 1,681
  • 8
  • 14