Skip to main content
Version: devel

dlt.common.data_writers.writers

FileWriterSpec Objects

class FileWriterSpec(NamedTuple)

View source on GitHub

file_format

format of the output file

data_item_format

format of the input data

supports_schema_changes

File format supports changes of schema: True - at any moment, Buffer - in memory buffer before opening file, False - not at all

file_max_items

Set an upper limit on the number of items in one file

DataWriter Objects

class DataWriter(abc.ABC)

View source on GitHub

item_format_from_file_extension

@classmethod
def item_format_from_file_extension(cls, extension: str) -> TDataItemFormat

View source on GitHub

Simple heuristic to get data item format from file extension

ImportFileWriter Objects

class ImportFileWriter(DataWriter)

View source on GitHub

May only import files, fails on any open/write operations

ModelWriter Objects

class ModelWriter(DataWriter)

View source on GitHub

Writes incoming items row by row into a text file and ensures a trailing ;

ArrowToObjectAdapter Objects

class ArrowToObjectAdapter()

View source on GitHub

A mixin that will convert object writer into arrow writer.

is_native_writer

def is_native_writer(writer_type: Type[DataWriter]) -> bool

View source on GitHub

Checks if writer has adapter mixin. Writers with adapters are not native and typically decrease the performance.

resolve_best_writer_spec

def resolve_best_writer_spec(
item_format: TDataItemFormat,
possible_file_formats: Sequence[TLoaderFileFormat],
preferred_format: TLoaderFileFormat = None) -> FileWriterSpec

View source on GitHub

Finds best writer for item_format out of possible_file_formats. Tries preferred_format first. Best possible writer is a native writer for item_format writing files in preferred_format. If not found, any native writer for possible_file_formats is picked. Native writer supports item_format directly without a need to convert to other item formats.

get_best_writer_spec

def get_best_writer_spec(item_format: TDataItemFormat,
file_format: TLoaderFileFormat) -> FileWriterSpec

View source on GitHub

Gets writer for item_format writing files in {file_format}. Looks for native writer first

create_import_spec

def create_import_spec(
item_file_format: TLoaderFileFormat,
possible_file_formats: Sequence[TLoaderFileFormat]) -> FileWriterSpec

View source on GitHub

Creates writer spec that may be used only to import files

This demo works on codespaces. Codespaces is a development environment available for free to anyone with a Github account. You'll be asked to fork the demo repository and from there the README guides you with further steps.
The demo uses the Continue VSCode extension.

Off to codespaces!

DHelp

Ask a question

Welcome to "Codex Central", your next-gen help center, driven by OpenAI's GPT-4 model. It's more than just a forum or a FAQ hub – it's a dynamic knowledge base where coders can find AI-assisted solutions to their pressing problems. With GPT-4's powerful comprehension and predictive abilities, Codex Central provides instantaneous issue resolution, insightful debugging, and personalized guidance. Get your code running smoothly with the unparalleled support at Codex Central - coding help reimagined with AI prowess.