RT::Ex...t::CSV(3pm)

πŸ“¦
version 2.5 Β· 3 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

RT-Extension-Assets-Import-CSV β€” RT Assets Import from CSV

okay so basically: this is the plugin that lets you yeet a whole CSV of assets into RT and have them show up as actual Assets. bestie, it's giving bulk import main character energy. πŸ¦‹

(this is the RT::Ex...t::CSV(3pm) page, iykyk ✨)


🌸 PREREQUISITES 🌸

This version of RT::Extension::Assets::Import::CSV requires RT 4.4, because that's the RT version where Assets are built in. no cap, they're just there. πŸ‘‘

If you're still running RT 4.2 with the Assets extension, you're gonna want an older version of this extension instead β€” specifically, version 1.4. she's vintage, she still slays. πŸŽ€


✨ INSTALLATION ✨

  1. Run these, in order:
perl Makefile.PL
make
make install
make install may need root permissions. πŸ’…
  1. Edit your /opt/rt5/etc/RT_SiteConfig.pm

Add this line:

Plugin('RT::Extension::Assets::Import::CSV');

See CONFIGURATION, below, for the remainder of the required configuration. yes, there's more. keep reading. πŸ“–

  1. Restart your webserver πŸ”„
  2. Run bin/rt-assets-import-csv

See bin/rt-assets-import-csv --help for more information. it's right there, bestie, just ask it. πŸ™ˆ


πŸŽ€ CONFIGURATION πŸŽ€

So like, imagine you've got a three-column CSV of assets and the column titled serviceTag is the unique one. This config is the vibe you'd use:

Set( $AssetsImportUniqueCF, 'Service Tag' );
Set( %AssetsImportFieldMapping,
    'Name'           => 'description',
    'CF.Service Tag' => 'serviceTag',
    'CF.Location'    => 'building',
    'CF.Serial #'    => 'serialNo',
);

πŸ’œ Constant values

Wanna set an RT column or custom field to one static value for every imported asset? Precede the "CSV field name" β€” that's the right hand side of the mapping β€” with a slash, like so:

Set( $AssetsImportUniqueCF, 'Service Tag' );
Set( %AssetsImportFieldMapping,
    'Name'           => 'description',
    'Catalog'        => \'Hardware',
    'CF.Service Tag' => 'serviceTag',
    'CF.Location'    => 'building',
    'CF.Serial #'    => 'serialNo',
);

Every imported asset will now be added to the Hardware catalog in RT. 🏷️ This feature is particularly useful for setting the asset catalog, but may also be useful when importing assets from CSV sources you don't control (and don't want to modify each time). lazy girlies rise, we love a shortcut. πŸ’…

🧚 Computed values

You may also compute values during import, by passing a subroutine reference as the value in the %AssetsImportFieldMapping. This subroutine will be called with a hash reference of the parsed CSV row. dynamic. iconic. periodt.

Set( $AssetsImportUniqueCF, 'Service Tag' );
Set( %AssetsImportFieldMapping,
    'Name'           => 'description',
    'CF.Service Tag' => 'serviceTag',
    'CF.Location'    => 'building',
    'CF.Weight'      => sub { $_[0]->{"Weight (kg)"} || "(unknown)" },
);
Using computed columns may cause false-positive "unused column" warnings; these can be ignored. not a real problem, bestie, don't spiral. 🫢

🌈 Numeric identifiers

If you're already using a numeric identifier to uniquely track your assets, and you wish RT to take over handling of that identifier, you can choose to leave $AssetsImportUniqueCF unset, and assign to id in the %AssetsImportFieldMapping:

Set( %AssetsImportFieldMapping,
    'id'             => 'serviceTag',
    'Name'           => 'description',
    'CF.Service Tag' => 'serviceTag',
    'CF.Serial #'    => 'serialNo',
);
⚠️ This requires that, after the import, RT becomes the generator of all asset ids. Otherwise, asset id conflicts may occur. fr fr, read that one twice. πŸ’€

⭐ Configuring Text::CSV_XS

This extension is built upon Text::CSV_XS, which takes a number of options for controlling its behavior. You may have a different field delimiter, or byte-order-marking (BOM), for example, and need to enable configuration to support it. Options set in %AssetsImportParserOptions will be passed directly to new() in Text::CSV_XS:

Set( $AssetsImportParserOptions, {
    binary     => 1,
    detect_bom => 1,
    sep_char   => '|',
});

The only default option is binary => 1. More information is available in the Text::CSV_XS documentation. go read it, she's thorough. πŸ“š


πŸ‘‘ AUTHOR πŸ‘‘

Best Practical Solutions, LLC <modules@bestpractical.com>


πŸ’€ BUGS πŸ’€

All bugs should be reported via email to

L<bug-RT-Extension-Assets-Import-CSV@rt.cpan.org|mailto:bug-RT-Extension-Assets-Import-CSV@rt.cpan.org>

or via the web at

L<rt.cpan.org|http://rt.cpan.org/Public/Dist/Display.html?Name=RT-Extension-Assets-Import-CSV>.

This extension is Copyright (C) 2014-2026 Best Practical Solutions, LLC.

This is free software, licensed under:

The GNU General Public License, Version 2, June 1991

okay that's the whole page, bestie, you ate. 🫢✨ this was the RT::Ex...t::CSV(3pm) page as shipped with perl v5.40.1 on 2026-02-14 β€” happy valentine's day to the perl toolchain and literally only the perl toolchain πŸ’– mwah, go import some assets πŸŽ€

πŸ“¦ where this page comes from