views:

65

answers:

1

I have table looks like this

------------------ 
GeneId | ProteinId
1      |    157 
2      |     - 
3      |    587     
4      |    897 
5      |     - 
6      |    120

In realational database, I can treat ProteinId column as INT and use NULL for "-" data. However, I can't find the same option in pytables. Does pytables support NULL ? Currently, I use "0" for NULL data.

+1  A: 

As the docs say,

Cells in a PyTables' table always have a value of the cell type, so there is no NULL. Instead, cells take a default value (zero or empty) which can be changed in the type declaration, like this: col_name = StringCol(10, dflt='nothing') (col_name takes the value 'nothing' if unset).

So, for integer columns, a default of 0 is normally used, and, no, alas!, there is no way to mark a value as missing or unknown, as NULL does in SQL.

Alex Martelli