Skip to main content

The Ingestion Game

The Ingestion Game consists of:

  1. A data file with a varying number of entries containing some data. It is shaped as a CSV where each row has an arbitrary number of key=value pairs separated by comma.
    key1=value1,key2=value2
    key3=value3
    key4=value4,key5=value5,key6=value6
    
  2. Not all keys are always important! Each time we play the game, the keys to process can be different. The rest are just considered noise. We want to ingest all the important keys.
  3. All important keys are always going to be present in the data rows of the input file.
  4. Each key supports a specific data type. We should only process rows where the values match the expected datatype of each key.
  5. Each row consists of an Entity of a given type. The type will be informed as type=T in the data. type is always considered as an important key and we can assume it is a str.
  6. Entities have hierarchies defined in the games' rules. For example, given the rule A -> B, we cannot process any Entity of type B until we have processed all Entities of type A.

Your task is to win the Ingestion Game with the following rules:

  • The important keys are id:int, name:str, food:str and type:str.
  • Entities follow the hierarchy A -> B -> C.

The solution must be coded in Python and you can use any public libraries. The solution must be an CLI that outputs the processed data to stdout in CSV format following the important keys, e.g.,:

id,name,food,type
1,levy,veggies,A
2,lima,pizza,A
3,john,fish,B

We are going to provide a data file with the keys and hierarchies mentioned above, but your CLI should accept any important keys and hierarchies as inputs. You can see an example on input data in the provided input.txt.

🤓 We value in the solution

  • Good software design
  • Proper documentation
  • Compliance to Python standards and modern usages (e.g.: PEP8)
  • Proper use of data structures
  • Ergonomy of the command line interface
  • Setup/Launch instructions if required

Solution

Install using pip:

pip install ingestion-game

Run

Help:

ingestion_game --help

Parameters:

  • IMPORTANT_KEYS: [required] separate by commas without spaces example: id:int,name:str,food:str,type:str
  • HIERARCHY: [required] separate by commas without spaces example: A,B,C
  • PATH: [required] path of the input file example: /files/input.txt

Example:

ingestion_game id:int,name:str,type:str A,B,C /file/input.txt

Release files for ingestion-game 0.1.3

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

Source distribution (sdist)

Source distribution for ingestion-game 0.1.3
File Size Uploaded
ingestion_game-0.1.3.tar.gz 19.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ingestion-game 0.1.3
File Interpreter ABI Platform
ingestion_game-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 38.6 kB

Release files / ingestion_game-0.1.3.tar.gz

Download URL ingestion_game-0.1.3.tar.gz
Size 19.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e4114041a54ffb47b07d28a17ec8a76e07f852b4e824a6352d59f584c6d1dbc3
BLAKE2b-256 checksum
How to use checksums
535f0ad7a46eda14f9ac7aa1c9e8c4803d23544fce40d3ed9fac0e097657ad16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release files / ingestion_game-0.1.3-py3-none-any.whl

Download URL ingestion_game-0.1.3-py3-none-any.whl
Size 19.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4a4c09d9bb381f1b1352694b63057fc758edc1bc144d0f36dd077903b8a9b486
BLAKE2b-256 checksum
How to use checksums
b45d516676ddfa56682622c17dcb88cb06a9cfdf790938dab5dec54a9878266f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

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