Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- KX Community
- :
- Discussion Forums
- :
- Developer Tools
- :
- Null Value for a Type

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Null Value for a Type

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

2015.02.27 01:59 AM

I was required in my scripts to insert null values for some column but because of number of columns were large, i thought to write a function that will give me such values. But somehow i was not able to find a direct way to find that null values for columns of table.

Temporarily i wrote following, not sure if it is correct:

;NullValDictionary:`b`g`x`h`i`j`e`f`c`s`p`m`d`z`n`u`v`t!(0b;0Ng;0x00;0Nh;0N;0Nj;0Ne;0n;" ";`;0Np;0Nm;0Nd;0Nz;0Nn;0Nu;0Nv;0Nt)

;AddNullValueBaseOnCol:{[tbll;startCol]

;metaCol:0!meta tbll

;cnt:count metaCol

; {NullValDictionary`$x`t} each metaCol (startCol-1)+til cnt-startCol-1

}

/ some existing table

;tbl:([]a:1 2 3 4 5;b:`a`b`c`d`e;c:"abcde")

/ following return an array of the null values from the column number 2

;AddNullValueBaseOnCol[tbl;2]

Please let me know if any better/right way.

4 REPLIES 4

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

2015.02.27 02:06 AM

to get a null type of a vector

q)first 0#010101b

0b

q)first each value flip 0#tbl

0N

`

" "

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

2015.02.27 02:11 AM

Thanks Charles!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

2015.02.27 12:24 PM

On Friday, February 27, 2015 at 5:06:36 AM UTC-5, Charles Skelton wrote:

to get a null type of a vectorq)first 0#010101b0b

I prefer using v[0N], v@0N, or just v 0N to get the null type for a vector v. You can also use -1 instead of 0N, but I find 0N more suggestive.

q)first each value flip 0#tbl0N`" "

q)@[;0N]each value flip tbl

0N

`

" "

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

2015.03.03 01:30 AM

Indexing out of domain will return a null.

first 0#x

also works for atoms, so it's a handy idiom to remember (and is one used by Arthur).

Main Office Contacts

**EMEA**

Tel: +44 (0)28 3025 2242

**AMERICAS**

Tel: +1 (212) 447 6700

**APAC**

Tel: +61 (0)2 9236 5700

Useful Information

Resources

Popular Links

Follow Us

KX. All Rights Reserved.

KX and kdb+ are registered trademarks of KX Systems, Inc., a subsidiary of FD Technologies plc.