Delimit.FixedWidth.Writer (delimit v0.4.2)

View Source

Functions for writing fixed-width data to files or strings.

This module handles serialization of structs into fixed-width format where each field occupies a specific number of characters.

Summary

Functions

Streams fixed-width data to a file.

Writes fixed-width data to a file.

Writes fixed-width data to a string.

Functions

stream_to_file(schema, path, data_stream, opts \\ [])

@spec stream_to_file(Delimit.Schema.t(), Path.t(), Enumerable.t(), Keyword.t()) :: :ok

Streams fixed-width data to a file.

Parameters

  • schema - The schema definition
  • path - Path to the output file
  • data_stream - Stream of structs to write
  • opts - Write options

Returns

  • :ok on success

write_file(schema, path, data, opts \\ [])

@spec write_file(Delimit.Schema.t(), Path.t(), [struct()], Keyword.t()) :: :ok

Writes fixed-width data to a file.

Parameters

  • schema - The schema definition
  • path - Path to the output file
  • data - List of structs to write
  • opts - Write options

Returns

  • :ok on success

write_string(schema, data, opts \\ [])

@spec write_string(Delimit.Schema.t(), [struct()], Keyword.t()) :: binary()

Writes fixed-width data to a string.

Parameters

  • schema - The schema definition
  • data - List of structs to write
  • opts - Write options (:line_ending, :headers)

Returns

  • String containing the fixed-width data