RT::Ex...t::CSV(3pm)
π NAME π
RT-Extension-Assets-Import-CSV β that's the whole personality: RT Assets Import from CSV. You got a spreadsheet, you got assets, this extension makes them meet. π
Oh and real quick, the page you're reading right now is filed under the manual name RT::Ex...t::CSV(3pm) β yes, it's squished and truncated like that, that's just how the header renders it, we move. β¨
πΈ PREREQUISITES πΈ
- This version of
RT::Extension::Assets::Import::CSVrequires RT 4.4, periodt β because that version of RT has Assets built right in. No extra extension, they just live there. Iconic. - If you're running RT 4.2 with the Assets extension, bestie, you need an older version of this extension β specifically version 1.4. Go get that one, it's the one for you. π«Ά
π INSTALLATION π
- Do the classic three-step. In order. No skipping:
perl Makefile.PL
make
make install
make install may need root permissions. Yeah. Sudo o'clock. π
- Edit your
/opt/rt5/etc/RT_SiteConfig.pmβ drop this line in:
Plugin('RT::Extension::Assets::Import::CSV');
Then go look at CONFIGURATION below, because that's where the rest of the required configuration lives. Don't skip it, it's not optional, fr fr.
- Restart your webserver. π«
- Run
bin/rt-assets-import-csv.
Want more deets on that script? See bin/rt-assets-import-csv --help.
π¦ CONFIGURATION π¦
So here's the scenario: you've got a three-column CSV of assets, and the column titled serviceTag is unique. That config would look exactly like this:
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 a custom field to a static value for every single 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',
);
Now every imported asset gets added to the Hardware catalog in RT. Obsessed, honestly. This feature is particularly useful for setting the asset catalog, but it also hits different when you're importing assets from CSV sources you don't control (and you do not want to hand-edit that file every single time). π ββοΈ
π§ Computed values π§
You can also compute values during import by passing a subroutine reference as the value in the %AssetsImportFieldMapping. That subroutine gets called with a hash reference of the parsed CSV row. Main character behavior:
Set( $AssetsImportUniqueCF, 'Service Tag' );
Set( %AssetsImportFieldMapping,
'Name' => 'description',
'CF.Service Tag' => 'serviceTag',
'CF.Location' => 'building',
'CF.Weight' => sub { $_[0]->{"Weight (kg)"} || "(unknown)" },
);
Heads up though: using computed columns may cause false-positive "unused column" warnings. These can be ignored. Not a bug, just noise, ignore it and thrive. π
π Numeric identifiers π
Already using a numeric identifier to uniquely track your assets, and you want RT to take over handling of that identifier? Say less. 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. And not the cute kind of conflict. So be sure before you commit, bestie.
π AUTHOR π
Best Practical Solutions, LLC <modules@bestpractical.com>
π BUGS π
All bugs should be reported via email to
bug-RT-Extension-Assets-Import-CSV@rt.cpan.org
or via the web at
http://rt.cpan.org/Public/Dist/Display.html?Name=RT-Extension-Assets-Import-CSV
(Those two are the same links the original page shows as L<bug-RT-Extension-Assets-Import-CSV@rt.cpan.org|mailto:bug-RT-Extension-Assets-Import-CSV@rt.cpan.org> and L<rt.cpan.org|http://rt.cpan.org/Public/Dist/Display.html?Name=RT-Extension-Assets-Import-CSV>, in case you're a purist. π«‘)
π COPYRIGHT π
This extension is Copyright (C) 2014-2021 Best Practical Solutions, LLC.
This is free software, licensed under:
The GNU General Public License, Version 2, June 1991
And that's the whole page, babe. π This one shipped as perl v5.34.0, dated 2022-06-24, and it goes by the manual name RT::Ex...t::CSV(3pm). Go import something cute. Byeee! πβ¨π¦
π¦ where this page comes from
- debian bookworm: rt-extension-assets-import-csv-common 2.3-1 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms