How do you extract numbers from a particular column composed of strings eg:
(`category:"abc 124M def 154M" ; "hij 120M hij 174M" ; "stu 126M def 166M" ; "abx 67M def 66M" )
Answer:
124,154
120,174
126,166
67,66
How do you extract numbers from a particular column composed of strings eg:
(`category:"abc 124M def 154M" ; "hij 120M hij 174M" ; "stu 126M def 166M" ; "abx 67M def 66M" )
Answer:
124,154
120,174
126,166
67,66
There might be more efficient answers out there, but this works:
q)f:{except[;0Nj]"J"$" "vs?[x in "0123456789";x;" "]}
q)category
"abc 124M def 154M"
"hij 120M hij 174M"
"stu 126M def 166M"
"abx 67M def 66M"
q)f each category
124 154
120 174
126 166
67 66
See 'inter'
q)myStrings:("he11o";"I am a p3rs0n")
q)myStrings inter\:.Q.n
"11"
"30"
q)
For your example, fixing up the syntax can give us the table:
show tab:([]category:("abc 124M def 154M" ; "hij 120M hij 174M" ; "stu 126M def 166M" ; "abx 67M def 66M"))
category
-------------------
"abc 124M def 154M"
"hij 120M hij 174M"
"stu 126M def 166M"
"abx 67M def 66M"
From here we can only include numeric chars and spaces with inter
, splitting on spaces and converting to get the numbers, excluding null values.
q){r@'where each not null r:"J"$" "vs/:x inter\:.Q.n," "}tab`category
124 154
120 174
126 166
67 66