exxeleron / qPython

interprocess communication between Python and kdb+
http://www.devnet.de
Apache License 2.0
152 stars 89 forks source link

Fix: Pandas deserialization of single row tables with string nulls #41

Closed maciejlach closed 7 years ago

maciejlach commented 7 years ago

As described in: http://stackoverflow.com/questions/39536229/issue-with-null-character-received-by-qpython-pandas-from-kdb

Pandas deserialization fails whenever kdb sends it a single row table where one of the columns has a blank char.

To reproduce:

from qpython import qconnection

q = qconnection.QConnection(pandas = True, host = 'myhost', port = myport)

print 'initiating connection(s)'
q.open()

while True:
    msg = q.receive(data_only = True, raw = False)
    print 'message received'

Now, on the kdb side:

/send a table (which just so happens to have blank/null chars)
neg[4](`upd;`trade;([] col1:`a`b`c;col2:"  a"))
/no problem

/send last row of that table
neg[4](`upd;`trade;-1#([] col1:`a`b`c;col2:"  a"))
/no problem

/send two rows (2 blank chars)
neg[4](`upd;`trade;2#([] col1:`a`b`c;col2:"  a"))
/no problem

/send first row of that table (one blank char)
neg[4](`upd;`trade;1#([] col1:`a`b`c;col2:"  a"))
/crashes with error "AttributeError: 'float' object has no attribute 'meta'"