tables_io

tables_io is a library of functions for input, output and conversion of tabular data formats

Submodules

Package Contents

Classes

LazyModule

A partial implementation of a lazily imported module.

TableDict

Object to collect various types of table-like objects

Functions

lazyImport(modulename)

Lazily load a module

Attributes

version

tables

apTable

apDiffUtils

fits

h5py

pa

pd

pq

jnp

convertObj

convert

writeNative

write

readNative

read

io_open

iteratorNative

iterator

version = 'unknown'[source]
class LazyModule(name)[source]

A partial implementation of a lazily imported module.

This isn’t a general solution, since it doesn’t actually create a module-like object, but the LazyLoader solution in importlib seems not to cope with submodules like astropy.table, or pyarrow.parquet, and always imports the full module.

property module
__dir__()[source]

Get the attributes of the module, to support tab-autocomplete.

__getattr__(item)[source]

Get something from the module

lazyImport(modulename)[source]

Lazily load a module

tables[source]
apTable[source]
apDiffUtils[source]
fits[source]
h5py[source]
pa[source]
pd[source]
pq[source]
jnp[source]
class TableDict[source]

Bases: collections.OrderedDict

Object to collect various types of table-like objects

This class is a dictionary mapping name to table-like and a few helper functions, e.g., to add new tables to the dictionary and to read and write files, either as FITS or HDF5 files.

__setitem__(key, value)[source]

Set self[key] to value.

write(basepath, fmt=None)[source]

Write tables to the corresponding file type

Parameters:
  • basepath (str) – base path for output files. Suffix will be added based on type

  • fmt (str or None) – The output file format, If None this will use writeNative

convert(tType)[source]

Build a new TableDict by converting all the table in the object to a different type

Parameters:

tType (int) – The type to convert to

Returns:

td – The new TableDict

Return type:

TableDict

classmethod read(filepath, tType=None, fmt=None, keys=None)[source]

Read a file to the corresponding table type

Parameters:
  • filepath (str) – File to load

  • tType (int or None) – Table type, if None this will use readNative

  • fmt (str or None) – File format, if None it will be taken from the file extension

  • keys (list or None) – Keys to read for parquet files

Returns:

tableDict – The data

Return type:

TableDict

convertObj[source]
convert[source]
writeNative[source]
write[source]
readNative[source]
read[source]
io_open[source]
iteratorNative[source]
iterator[source]