1

Is there a way to get string representation of k object, similar (better identical) to that printed to q console?

q)([]a:`a`b`c;b:"abc";c:1 2 3)
a b c
-----
a a 1
b b 2
c c 3
q)
thefourtheye
  • 233,700
  • 52
  • 457
  • 497
user443854
  • 7,096
  • 13
  • 48
  • 63

3 Answers3

1

There are much better ways to do io with kdb.

With csv you can, for example, store tables:

save `:table.csv

or return tables:

http://host:port/q.csv?table

For more on C/C++ integration, see http://code.kx.com/q/interfaces/using-c-functions/

Thomas Smyth - Treliant
  • 4,993
  • 6
  • 25
  • 36
nightTrevors
  • 639
  • 4
  • 11
  • 24
1

.Q.s is used to format something for console printing, can use this to get the q console string.

q)t:([]a:`a`b`c;b:"abc";c:1 2 3)
q)show .Q.s t
    "a b c\n-----\na a 1\nb b 2\nc c 3\n"
q)t:([]a:`a`b`c;b:"abc";c:1 2 3)
q)show str:.Q.s t
    "a b c\n-----\na a 1\nb b 2\nc c 3\n"
q)-1 str;
    a b c
    -----
    a a 1
    b b 2
    c c 3

.Q.s1 can be used to get the single line version of the string.

q).Q.s1 t
   "+`a`b`c!(`a`b`c;\"abc\";1 2 3)"
MdSalih
  • 1,978
  • 10
  • 16
0

I did some work on C interface with KDB+. It involves printing and creating KDB+ objects using C.

http://code.kx.com/wsvn/code/contrib/aquaqanalytics/InterfacingKDBtoC/?#ab109deb48fbdcebdc610ae05c54e9ede

It might be a bit different in C++ but it should be a starting point for you?

Hope this helps.

WooiKent Lee
  • 1,301
  • 6
  • 4