NAME

Protocol::IR::Format::CSV - IRDB CSV importer

VERSION

version 0.08

SYNOPSIS

use Protocol::IR::Converter;

my $converter = Protocol::IR::Converter->new();

# Parse an IRDB-style CSV string
my $csv = "functionname,protocol,device,subdevice,function\n"
        . "KEY_POWER,NEC1,4,0,8\n";
my $codes = $converter->import_format('CSV', $csv);

for my $code (@$codes) {
    print $code->alias . "\n";
    print $converter->export_code($code, 'Pronto') . "\n";
}

# Or load from a file path
my $codes = $converter->import_format('CSV', 'remote.csv');

DESCRIPTION

Protocol::IR::Format::CSV imports IRDB-style CSV button listings into Protocol::IR::Code objects. It accepts either a CSV string or the path to a CSV file.

Column headers are detected automatically. Recognized header aliases:

  • functionname, function_name, key, alias, label, name -- button name (stored on the alias accessor)

  • protocol, proto -- protocol name

  • device, address, addr, dev -- device (address)

  • subdevice, subaddress, subaddr, subdev -- subdevice

  • function, command, cmd, code -- command

  • data, hex, raw -- a raw value for the protocol

A row is decoded either from a raw data value or, when no data column is present, from the device/subdevice/command columns. Protocol aliases such as NEC1 and nec are normalized to NEC; the IRDB NEC-family variants NEC2, NECx1, and NECx2 are kept as-is, so the variant identity survives the conversion. Each decoded code gets its alias set from the button name column.

METHODS

decode

my $codes = $class->decode($input, $registry);

Parses a CSV string or file and returns an arrayref of Protocol::IR::Code objects. Rows with an unregistered or unrecognized protocol are skipped.

SUPPORT

Source code: https://github.com/bwarden/perl-protocol-ir

Bug reports and feature requests: https://github.com/bwarden/perl-protocol-ir/issues

AUTHOR

Brett T. Warden <bwarden@cpan.org>

COPYRIGHT AND LICENSE

Copyright (c) 2026 Brett T. Warden

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation.