Skip to main content

RecordMapper

Read, transform and write records using an Avro schema and custom map functions.

Installing the project

To install the project, run the following command from the root directory:

$pip install .

It is highly recommended to use a virtual environment when installing the project dependencies in order to avoid version conflicts.

Updating PyPI version

poetry publish --build

RecordMapper elements

Appliers

Appliers are the elements that materialise the records transformations. They apply sequentially specific transformations to each record and/or its schema.

There are four appliers defined by now:

  • The selector applier, which will modify the base schema if there exist nested schemas to consider.
  • The rename applier, which will develop a renaming process using the aliases included in the schema.
  • The transform applier which will apply the record transformations given the transforming functions.
  • The clean applier, which will filter the output fields to keep only the ones given in the output schema.

An Applier is a class that implements the apply method, which receives a single record and its schema and returns their transformed version after the transforming process. They are located in the appliers directory.

Readers

To apply the records transformations, the Record Mapper must be able to read the file that contains the data in order to extract them. The Record Mapper supports reading files from different formats, including csv, xml and avro.

The reading process is done by the Reader objects. A Reader class implements methods to read different kind of files. The Reader class is extended by sub-classes, each of them specialized in reading an specific format. For example, to read an XML file we can use the XMLReader class. To extract data from a CSV file, we will be using the CSVReader class.

A Reader sub-class implements the read_records_from_input method, which will return the content of the file record by record. Each specific Reader sub-class is located in the directory of its own format, sharing space with the correspondent Writer sub-class.

Writers

After applying the records transformations, the Record Mapper must be able to write the resultant transformed records in a file. It supports writing files for different formats, including csv and avro.

Important! The Record Mapper can return different files as output, one for each format, but at least it is mandatory to write the avro file. Thus, avro file is always returned.

The writing process is done by the Writer objects. A Writer class implements methods to write to different formats. The Writer class is extended by sub-classes, each of them specialized in writing an specific format. For example, to write a CSV file we can use the CSVWriter class while we will be using the AvroWriter to write an Avro file.

A Writer sub-class implements the write_records_to_output method, which will write a given iterable of records in an output file. Each specific Writer sub-class is located in the directory of its own format, sharing space with the correspondent Reader sub-class. The method accepts other output options as parameters. These output options include:

  • Flattening nested schemas when writing csv files.
  • Merging schemas when writing avro files.

Metadata

Release files for recordmapper 0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for recordmapper 0.7
File Size Uploaded
RecordMapper-0.7.tar.gz 16.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for recordmapper 0.7
File Interpreter ABI Platform
RecordMapper-0.7-py3-none-any.whl Python 3 none any Details

Total release size: 39.1 kB

Release files / RecordMapper-0.7.tar.gz

Download URL RecordMapper-0.7.tar.gz
Size 16.3 kB
Tags Source
SHA-256 checksum
How to use checksums
cee183fe7fcc3f65f033b321a71a2b183c376135fffe0ce57233e39c42f78b4b
BLAKE2b-256 checksum
How to use checksums
e9172b6b7c6e3e4e1210e1cc5960e51002fb5d1a8d21583f91bcf8ba45fe2994
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.6 CPython/3.9.0 Darwin/20.3.0

Release files / RecordMapper-0.7-py3-none-any.whl

Download URL RecordMapper-0.7-py3-none-any.whl
Size 22.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ab5602908d475b763f623e24e79a1cf8d1392b75bf65bdc2b1bc4c7fae4be47a
BLAKE2b-256 checksum
How to use checksums
bfa870f13a27076214dc0660d7f405caab62f99238fc681d90e547fbf330f2d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.6 CPython/3.9.0 Darwin/20.3.0

Release history Release notifications | RSS feed

This release

0.7 This release

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page