Welcome to JiKe DevOps Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
221 views
in Technique[技术] by (71.8m points)

用tableInsert写入字典报错

我在DolphinDB database GUI中执行下面代码往字典插入数据:

t=table(1 2 3 as x, 4 5 6 as y);
d=dict(`x`y, 4 7);
tableInsert(t, d);

报错:

The number of table columns doesn't match the number of columns to append.

请问是哪里写错了呢?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to answer this question.

1 Answer

0 votes
by (71.8m points)

tableInsert使用字典作为输入的时候,字典的值类型必须是ANY。这样根据字段名称,可以快速获取一个tuple,插入到table。请把代码修改为:

t=table(1 2 3 as x, 4 5 6 as y)
d=dict(`x`y, (4, 7))
tableInsert(t, d)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to JiKe DevOps Community for programmer and developer-Open, Learning and Share
...