[Bps-public-commit] rt-extension-assets-import-csv branch pass-opts-to-text-csv-xs created. 2.3-2-g3b65d2f
BPS Git Server
git at git.bestpractical.com
Fri Apr 12 15:55:36 UTC 2024
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt-extension-assets-import-csv".
The branch, pass-opts-to-text-csv-xs has been created
at 3b65d2f7a9db78b93513f21751abd604eadeebfc (commit)
- Log -----------------------------------------------------------------
commit 3b65d2f7a9db78b93513f21751abd604eadeebfc
Author: Jason Crome <jcrome at bestpractical.com>
Date: Fri Apr 12 11:52:42 2024 -0400
Pass config options directly to Text::CSV_XS
There are instances where files use a different delimiter, have
byte-order-marking, or something unsupported by the default
configuration set for Text::CSV_XS. This adds a config option that
passes configuration parameters directly to Text::CSV_XS->new(), so
files don't have to be massaged in order to import them.
diff --git a/lib/RT/Extension/Assets/Import/CSV.pm b/lib/RT/Extension/Assets/Import/CSV.pm
index 29e3b04..16db5e8 100644
--- a/lib/RT/Extension/Assets/Import/CSV.pm
+++ b/lib/RT/Extension/Assets/Import/CSV.pm
@@ -288,7 +288,8 @@ sub parse_csv {
my $file = shift;
my @rows;
- my $csv = Text::CSV_XS->new( { binary => 1 } );
+ my $opts = RT->Config->Get( 'AssetsImportParserOptions' ) // { binary => 1 };
+ my $csv = Text::CSV_XS->new( $opts );
open my $fh, '<', $file or die "failed to read $file: $!";
my $header = $csv->getline($fh);
@@ -418,6 +419,24 @@ the C<%AssetsImportFieldMapping>:
This requires that, after the import, RT becomes the generator of all
asset ids. Otherwise, asset id conflicts may occur.
+=head2 Configuring Text::CSV_XS
+
+This extension is built upon L<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
+C<%AssetsImportParserOptions> will be passed directly to C<new()> in
+L<Text::CSV_XS>:
+
+ Set( $AssetsImportParserOptions, {
+ binary => 1,
+ detect_bom => 1,
+ sep_char => '|',
+ });
+
+The only default option is C<binary => 1>. More information is available
+in the L<Text::CSV_XS> documentation.
+
=head1 AUTHOR
Best Practical Solutions, LLC E<lt>modules at bestpractical.comE<gt>
-----------------------------------------------------------------------
hooks/post-receive
--
rt-extension-assets-import-csv
More information about the Bps-public-commit
mailing list