PyVRL: Python Interface for Vector Remap Language (VRL)

0.0.2 · active · verified Fri Apr 17

PyVRL is a Python library that allows you to execute Vector Remap Language (VRL) transformations directly within your Python applications. It provides bindings to the VRL compiler and runtime, enabling data manipulation, filtering, and routing with VRL expressions. The current version is 0.0.2, indicating it's in very early development with an irregular release cadence.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to compile a VRL expression and execute it on a Python dictionary, ensuring data is correctly converted to and from `pyvrl.value.Value` objects.

from pyvrl.compiler import VRLCompiler
from pyvrl.value import Value

# Initialize the VRL compiler
compiler = VRLCompiler()

# Compile a VRL program to uppercase the 'message' field
vrl_program = '.message = upcase(.message)'
compiled_program = compiler.compile(vrl_program)

# Prepare input data as a pyvrl.value.Value object
input_data = Value({"message": "hello world"})

# Run the VRL program
output_data = compiled_program.run(input_data)

# Convert the output back to a Python dictionary
result = output_data.as_python()

print(f"Input: {input_data.as_python()}")
print(f"Output: {result}")
# Expected output: {'message': 'HELLO WORLD'}

view raw JSON →