Skip to main content
Version: 1.3.0

Data Size

Parse Data Analysis

Synopsis

Parses human-readable data sizes (e.g., "1kb") to byte values.

Schema

- data_size:
field: <ident>
target_field: <string>
output_format: <string>
description: <text>
if: <script>
ignore_failure: <boolean>
ignore_missing: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>

Configuration

The following fields are used to define the processor:

FieldRequiredDefaultDescription
fieldY-Source field containing human-readable data size
target_fieldNSame as fieldTarget field to store parsed byte value
output_formatNbytesOutput format: bytes (number) or detailed (object)
descriptionN-Explanatory note
ifN-Condition to run
ignore_failureNfalseContinue processing if parsing fails
ignore_missingNfalseSkip processing if referenced field doesn't exist
on_failureN-See Handling Failures
on_successN-See Handling Success
tagN-Identifier

Details

Converts human-readable data size strings to numerical byte values. Supports common size units including bytes (B), kilobytes (KB), megabytes (MB), gigabytes (GB), terabytes (TB), and their binary equivalents (KiB, MiB, GiB, TiB).

The processor recognizes various formats including "1.5GB", "512 MB", "2TB", and handles both decimal (1000-based) and binary (1024-based) calculations depending on the unit suffix.

note

The processor supports both decimal units (KB, MB, GB using 1000-based calculations) and binary units (KiB, MiB, GiB using 1024-based calculations). Units are case-insensitive.

When output_format is set to "detailed", the processor returns an object containing both the original value, parsed number, unit, and calculated bytes.

warning

If the input string cannot be parsed as a valid data size, the processor will fail unless ignore_failure is set to true. Invalid units or malformed size strings will trigger errors.

Examples

Basic Size Parsing

Converting readable size to bytes...

{
"file_size": "1.5GB"
}
- data_size:
field: file_size
target_field: size_bytes

converts to byte value:

{
"file_size": "1.5GB",
"size_bytes": 1500000000
}

Binary Units

Using binary (1024-based) units...

{
"memory_usage": "512 MiB"
}
- data_size:
field: memory_usage
target_field: memory_bytes

calculates using 1024-based units:

{
"memory_usage": "512 MiB",
"memory_bytes": 536870912
}

Detailed Output

Getting detailed parsing information...

{
"disk_space": "2.5 TB"
}
- data_size:
field: disk_space
output_format: detailed
target_field: disk_info

returns detailed breakdown:

{
"disk_space": "2.5 TB",
"disk_info": {
"original": "2.5 TB",
"value": 2.5,
"unit": "TB",
"bytes": 2500000000000,
"type": "decimal"
}
}

Mixed Case Units

Processing case-insensitive units...

{
"bandwidth": "100 mb"
}
- data_size:
field: bandwidth

handles case variations:

{
"bandwidth": "100 mb",
"bandwidth": 100000000
}