Convert symbol to a list of symbols

  • A+

I read in a csv file:

csvFile:1!("SSS"; enlist ",") 0: hsym `$"////location//of//csv"; 

But lists of symbols are read as single symbols. e.g. in the csv file I have 'a'b'c but

csvFile`some_keyed_value `col1`col2!``a`b`c` 

What I want is this - and note how a single ticker should be an empty list:


Is there a way to make this cast or read in the csv differently or modify the csv so that it reads in correctly? Any modifications I make to the csv (e.g. replacing ' with () ) simply converts it to a single symbol (e.g. I get '() ).

Here is a screenshot of a few lines from the csv

Convert symbol to a list of symbols

Taking this csv as an example:

cat ex.csv x,y `aa`bb, `cc`dd,`ee`ff ,`gg`hh 

You need to load those nested symbol columns in as strings first:

q)show tab:("**";enlist",")0:`:ex.csv x        y ----------------- "`aa`bb" "" "`cc`dd" "`ee`ff" ""       "`gg`hh" 

From here you then need to drop the backticks and convert the strings to symbols. One possible way to do this is:

q)update {`$1_'where["`"=x]cut x}'[x] from tab x          y ------------------- `aa`bb     "" `cc`dd     "`ee`ff" `symbol$() "`gg`hh" 


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: