RE: [personal kdb+] Re: Split a column of strings and enumerate them

User-Agent: Workspace Webmail 5.14.4Message-Id: <20150629112039.85f80dae80d1d2f2e266ec6278e6cbe8.232ac262fd.wbe@email07.europe.secureserver.net>From: “David Demner (AquaQ)” <david.demner>To: personal-kdbplus@googlegroups.comSubject: RE: [personal kdb+] Re: Split a column of strings and enumerate themDate: Mon, 29 Jun 2015 11:20:39 -0700Mime-Version: 1.0

The problem is str[;0] will return a list of chars, which is actually a string and thus collapses to a single row. You can enlist each element individually to make each cell a string:


q)update col1:`$enlist each str[;0], col2:`$enlist each str[;1], col3:`$enlist each str[;2], col4:`$enlist each str[;3]
from t
str col1 col2 col3 col4
--------------------------
"T " T
" FT" F T
" C" C

or change how to create the table:
q)flip `col1`col2`col3`col4!`$(enlist each)@' flip t`str
col1 col2 col3 col4
-------------------
T
F T
C

then use enumerate that.

If you want to enumerate not using the sym file or .Q.en you have to do it manually. easiest is to create a new .Q.en and replace `sym with whatever. Or you can enumerate manually, like at http://code.kx.com/wiki/JB:QforMortals/casting_and_enumerations#Enumerations

Good luck,

David



Thanks very much David

q)c1c2c3c4!/:$''tstr
c1 c2 c3 c4

T         
      F  T
         C