Reputation: 133
I have a table which has column of symbol type like below.
Name | Value |
---|---|
First | TP_RTD_FRV |
Second | RF_QWE_FRV |
Third | KF_FRV_POL |
I need to update it as below, wherever I have FRV, I need to replace it with AB_FRV. How to achieve this?
Name | Value |
---|---|
First | TP_RTD_AB_FRV |
Second | RF_QWE_AB_FRV |
Third | KF_AB_FRV_POL |
Upvotes: 0
Views: 1130
Reputation: 1111
q)t
name v
---------------
0 TP_RTD_FRV
1 RF_QWE_FRV
2 KF_FRV_POL
3 THIS
4 THAT
q)update `$ssr[;"FRV";"AB_FRV"]each string v from t
name v
------------------
0 TP_RTD_AB_FRV
1 RF_QWE_AB_FRV
2 KF_AB_FRV_POL
3 THIS
4 THAT
or without using qSQL
q)@[t;`v;]{`$ssr[;"FRV";"AB_FRV"]each string x}
name v
------------------
0 TP_RTD_AB_FRV
1 RF_QWE_AB_FRV
2 KF_AB_FRV_POL
3 THIS
4 THAT
Depending on the uniqueness of the data, you might benefit from .Q.fu
q)t:1000000#t
q)\t @[t;`v;]{`$ssr[;"FRV";"AB_FRV"]each string x}
2343
q)\t @[t;`v;].Q.fu {`$ssr[;"FRV";"AB_FRV"]each string x}
10
Upvotes: 5