KDB-SSR在单个,双引号符号colum上

发布于 2025-01-23 20:04:21 字数 1314 浏览 0 评论 0原文

我有一个最近更改的数据源(但是同一表),我正在尝试清理我的表格,并使用讨厌的字符”,我试图用null

将表推到KDB时,它是一个可以具有单个双引号(ASCII 34的符号列)。 >使用填充填充数据源更改之前的某个点。很好,因此

由于某种原因,我无法进行ssr函数。 不是吗

想法

我的

// update query does not fail but doesn't update the single, double quote in seg
t: update seg: fills `$ssr[;"\"\"";""] each string seg from t; 

//verify the data types are symbols
meta t;
c            | t f a
-------------| -----
id           | s
seg          | s

?我尝试将SEG施放为字符串,以了解如何逃脱报价以及所需的目标。

id       seg      Displaystring    Ticker  ---->> Desired output
------------------------------------------------------
AAA  1   GOOG    "GOOG"            GOOG
AAA  2   "       ,"\""             GOOG
AAA  3   "       ,"\""             GOOG
AAA  4   "       ,"\""             GOOG
AAA  5   "       ,"\""             GOOG
AAA  6   "       ,"\""             GOOG
BBB  1   AMZN    "AMZN"            AMZN
BBB  2   "       ,"\""             AMZN
BBB  3   "       ,"\""             AMZN
CCC  1   AAPL    "AAPL"            AAPL
CCC  2   "       ,"\""             AAPL
CCC  3   "       ,"\""             AAPL
DDD  1   TSLA    ,"\""             TSLA
DDD  2   "       ,"\""             TSLA

I have a datasource that changed recently (same table however) and I am trying to clean up my table and having an issue with a pesky character " that I am trying to replace with null

When the table is pushed to kdb, it is a symbol column that can have a single double quote (ascii 34.) I have been running ssr to replace it with null and using fills to populate which it had worked at one point before the datasource change. I thought it might be a leading/trailing spaces so I checked with trim which seems to be fine so no rogue spaces are included.

For some reason, I am unable to perform ssr function on it. I'm verifying that the char is correct. I thought I had it working however my update below doesn't.

Any thoughts? I'm assuming its my regex?

P.S. I was hoping to avoid having to use the 'int $ seg to cast it as ascii but that is my next idea.

// update query does not fail but doesn't update the single, double quote in seg
t: update seg: fills `$ssr[;"\"\"";""] each string seg from t; 

//verify the data types are symbols
meta t;
c            | t f a
-------------| -----
id           | s
seg          | s

Here is my attempt at casting the seg as string to see how to escape the quote as well as the desired goal.

id       seg      Displaystring    Ticker  ---->> Desired output
------------------------------------------------------
AAA  1   GOOG    "GOOG"            GOOG
AAA  2   "       ,"\""             GOOG
AAA  3   "       ,"\""             GOOG
AAA  4   "       ,"\""             GOOG
AAA  5   "       ,"\""             GOOG
AAA  6   "       ,"\""             GOOG
BBB  1   AMZN    "AMZN"            AMZN
BBB  2   "       ,"\""             AMZN
BBB  3   "       ,"\""             AMZN
CCC  1   AAPL    "AAPL"            AAPL
CCC  2   "       ,"\""             AAPL
CCC  3   "       ,"\""             AAPL
DDD  1   TSLA    ,"\""             TSLA
DDD  2   "       ,"\""             TSLA

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

救星 2025-01-30 20:04:21

这应该做这项工作

q)tab:([]id:`$raze{x,/:string 1+til y}'[("AAA ";"BBB ";"CCC ";"DDD ");6 3 3 2];seg:@[`
14#"\"";0 6 9 12;:;`GOOG`AMZN`AAPL`TSLA])
q)tab
id    seg
----------
AAA 1 GOOG
AAA 2 "
AAA 3 "
AAA 4 "
AAA 5 "
AAA 6 "
BBB 1 AMZN
BBB 2 "
BBB 3 "
CCC 1 AAPL
CCC 2 "
CCC 3 "
DDD 1 TSLA
DDD 2 "
q)update fills?[seg=`$"\"";`;seg]from tab
id    seg
----------
AAA 1 GOOG
AAA 2 GOOG
AAA 3 GOOG
AAA 4 GOOG
AAA 5 GOOG
AAA 6 GOOG
BBB 1 AMZN
BBB 2 AMZN
BBB 3 AMZN
CCC 1 AAPL
CCC 2 AAPL
CCC 3 AAPL
DDD 1 TSLA
DDD 2 TSLA

This should do the job

q)tab:([]id:`$raze{x,/:string 1+til y}'[("AAA ";"BBB ";"CCC ";"DDD ");6 3 3 2];seg:@[`
14#"\"";0 6 9 12;:;`GOOG`AMZN`AAPL`TSLA])
q)tab
id    seg
----------
AAA 1 GOOG
AAA 2 "
AAA 3 "
AAA 4 "
AAA 5 "
AAA 6 "
BBB 1 AMZN
BBB 2 "
BBB 3 "
CCC 1 AAPL
CCC 2 "
CCC 3 "
DDD 1 TSLA
DDD 2 "
q)update fills?[seg=`
quot;\"";`;seg]from tab
id    seg
----------
AAA 1 GOOG
AAA 2 GOOG
AAA 3 GOOG
AAA 4 GOOG
AAA 5 GOOG
AAA 6 GOOG
BBB 1 AMZN
BBB 2 AMZN
BBB 3 AMZN
CCC 1 AAPL
CCC 2 AAPL
CCC 3 AAPL
DDD 1 TSLA
DDD 2 TSLA
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文