如何将 KDB 查询输出写入文本文件

问题描述 投票:0回答:1
filePath:hsym `$("/c/d/f/a.txt");
.co.fileHandle: hopen filePath;
x:select a,c from tab
neg[.co.fileHandle]  x

neg[.co.fileHandle] x >> 抛出类型:类型不匹配错误

我知道我可以直接将其另存为`:/c/d/f/x.txt。但是,在将查询输出写入 a.txt 后,我还想添加其他查询的输出。

kdb q
1个回答
0
投票

这只允许将一个字符串或字符串列表附加到文件中。可以使用

.Q.s
将表格转换为字符串。

q)neg[.co.fileHandle] .Q.s x

然后可以验证文件包含输出

> cat /c/d/f/a.txt
a c
---
1 a
2 b
3 c

© www.soinside.com 2019 - 2024. All rights reserved.