Table Datatypes

Read a table in from remote data, however on parsing one of the fields of Type C has 0nf, how do you exclude these from a select/delete these rows, have tried casting, null, they all return a type error. Have just deleted the column from the table however am interested in the underlying cause.

?are you using 0: or other parser?  

what does your parse code look like??

what does a line of data look like that produces the 0nf?

Maybe you can use “meta table” and check if column X is in type C then exclude it?

q)show t:(a:1 2 3;b:(“one”;“two”;0nf))

a b    

1 “one”
2 “two”
3 0n  


q)meta t

c| t f a
-| -----
a| j
b| C

q)select from t where not all each null each b

a b
-------
1 “one”
2 “two”

Or using compose, which I think makes it easier to read:

q)select from t where not ('[all;null] each b)

a b
-------
1 “one”
2 “two”

Alternatively:


q)select from t where not(all null@)'[b]

a b

-------

1 “one”

2 “two”

q)select from t where not(all null@)each b

a b

-------

1 “one”

2 “two”

I would apply the null first, as it’s atomic, rather than test the null-ness repeatedly

q)\ts:10000 select from t where not all each null b

20 1648

q)\ts:10000 select from t where not(all null@)'[b]

31 1840

Another option would be to create the nulls for all datatypes first and test for their existence (avoids the multiple each-es)

q)nu:(enlist[()],(.Q.t;" ") 0: “”)

q)select from t where not b in nu

a b


1 “one”

2 “two”

But as Jack mentioned - best course of action is to try and omit these “extra” operations and find out where and why the nulls are appearing.