KDB将一个表格复制一个表格(meta)到另一个表格
我正在尝试将一个表的模式映射到另一个表格,
例如,我有t1
和t2
,它们具有精确的列名和顺序,但数据类型不同,但是我想要(META T2)〜META T1。 // 1B
。
我的想法是使用t1
使用meta
的数据类型字符串,说是“ sffffffjjj”
。然后将T2
存储到.csv,并使用“ sffffffjjj”
读取它。这起作用,但不聪明,有人能提出更好的想法吗?
I'm trying to map one table's schema to another table,
For instance, I have t1
and t2
, which have exact column names and order but different datatype, but I want (meta t2)~meta t1. //1b
.
My idea is to copy datatype string of t1
using meta
, say it's "SFFFFFJJJ"
. Then store t2
to .csv and read it with "SFFFFFJJJ"
. This works but not smart, could anyone come up with better ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用一个表的元表铸出另一个表:
t2:flip(frof from Meta t1)$ string flip flip t2
You could use the meta of one table to cast the other table:
t2:flip(exec upper t from meta t1)$string flip t2
这是基于与您提到的相同原则的基础,而无需保存CSV形式的表:
这将返回表
t1
,但使用t2
的架构。在这里,
“,”,“ 0:x
是准备文本将表转换为字符串列表,并由逗号界定数据。(...; ...)0:
是加载csv 在提供类型的地方t2
的元表。This is based on the same principle as you mention, without the need to save the csv-formatted table:
This will return the table
t1
but with the schema oft2
.Here,
","0:x
is Prepare Text which converts the table into a list of strings, with data delimited by commas. The(...;...)0:
is Load CSV where the types are being suppliedt2
's meta table.