tableserializer.serializer module
Submodules
tableserializer.serializer.metadata module
- class tableserializer.serializer.metadata.MetadataSerializer[source]
Bases:
ABC,SignatureProvidingInstanceSerializer for table-related metadata objects. Defines a strategy for serializing the metadata contents in a specific way.
- class tableserializer.serializer.metadata.PairwiseMetadataSerializer[source]
Bases:
MetadataSerializerMetadata serializer that serializes entries in the metadata dictionary as “key: value” pairs.
- class tableserializer.serializer.metadata.JSONMetadataSerializer[source]
Bases:
MetadataSerializerMetadata serializer that serializes the full metadata dictionary as JSON.
tableserializer.serializer.schema module
- class tableserializer.serializer.schema.SchemaSerializer[source]
Bases:
ABC,SignatureProvidingInstanceSerializer for the schema captured in the table.
- abstractmethod serialize_schema(table: Table, metadata: Dict[str, Any] | None = None) str[source]
Serialize the schema captured in the table.
- Parameters:
table (Table) – The table whose schema should be serialized.
metadata (Optional[Dict[str, Any]]) – Optional metadata about the table.
- Returns:
Serialized schema string.
- Return type:
str
- class tableserializer.serializer.schema.ColumnNameSchemaSerializer(column_name_separator: str = '|')[source]
Bases:
SchemaSerializerSchema serializer that serializes the schema as a separated list of column names.
- Parameters:
column_name_separator (str) – Separator between column names.
- serialize_schema(table: Table, metadata: Dict[str, Any] | None = None) str[source]
Serialize the schema captured in the table.
- Parameters:
table (Table) – The table whose schema should be serialized.
metadata (Optional[Dict[str, Any]]) – Optional metadata about the table.
- Returns:
Serialized schema string.
- Return type:
str
- class tableserializer.serializer.schema.SQLSchemaSerializer(metadata_table_name_field: str | None = None, default_table_name: str = 'table')[source]
Bases:
SchemaSerializerSchema serializer that serializes the schema as a SQL CREATE TABLE statement.
- Parameters:
metadata_table_name_field (Optional[str]) – Optional: Provide the name of the field in the metadata that specifies the table name.
default_table_name (str) – Default table name used in schema when no specific table name is available through the metadata.
- serialize_schema(table: Table, metadata: Dict[str, Any] | None = None) str[source]
Serialize the schema captured in the table.
- Parameters:
table (Table) – The table whose schema should be serialized.
metadata (Optional[Dict[str, Any]]) – Optional metadata about the table.
- Returns:
Serialized schema string.
- Return type:
str
tableserializer.serializer.serializer module
- class tableserializer.serializer.serializer.Serializer(recipe: SerializationRecipe, metadata_serializer: MetadataSerializer | None = None, schema_serializer: SchemaSerializer | None = None, table_serializer: RawTableSerializer | None = None, row_sampler: RowSampler | None = None, table_preprocessors: List[TablePreprocessor] | None = None)[source]
Bases:
objectSerializer that serializes a given table according to a user-specified format.
- Parameters:
recipe (SerializationRecipe) – The recipe detailing the serialization.
metadata_serializer (MetadataSerializer) – Serializer for the table metadata. Only needed if there is metadata placeholder in the recipe.
schema_serializer (SchemaSerializer) – Serializer for the table schema. Only needed if there is schema placeholder in the recipe.
table_serializer (RawTableSerializer) – Serializer for the raw table. Only needed if there is table placeholder in the recipe.
row_sampler (RowSampler) – Optional module that samples a number of rows from the raw table before serializing.
table_preprocessors (List[TablePreprocessor]) – Optional list of table preprocessors that transform the table before serialization.
- serialize(table: List[Dict[str, str]] | DataFrame | List[List[str]], metadata: Dict[str, Any]) str[source]
Serialize a given table.
- Parameters:
table (Table) – Table to serialize.
metadata (Dict[str, Any]) – Metadata of the table to serialize.
- Returns:
String serialization of the table.
- Return type:
str
tableserializer.serializer.table module
- class tableserializer.serializer.table.RawTableSerializer[source]
Bases:
ABC,SignatureProvidingInstanceSerializer for serializing raw tables to string representations.
- class tableserializer.serializer.table.JSONRawTableSerializer[source]
Bases:
RawTableSerializerSerializer for serializing raw tables to row-wise JSON representations.
- class tableserializer.serializer.table.MarkdownRawTableSerializer[source]
Bases:
RawTableSerializerSerializer for serializing raw tables to markdown representations.
- class tableserializer.serializer.table.CSVRawTableSerializer(separator=',')[source]
Bases:
RawTableSerializerSerializer for serializing raw tables to csv representations.
- Parameters:
separator (str) – Separator to use between values.
- class tableserializer.serializer.table.LatexRawTableSerializer[source]
Bases:
RawTableSerializerSerializer for serializing raw tables to LaTeX representations.