[Bps-public-commit] rt-extension-assets-import-csv branch add-separator-support created. 2.3-3-gc78e223

BPS Git Server git at git.bestpractical.com
Mon Oct 2 14:24:41 UTC 2023


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, add-separator-support has been created
        at  c78e223264a63cec9b3588d474a0d0f1d556339e (commit)

- Log -----------------------------------------------------------------
commit c78e223264a63cec9b3588d474a0d0f1d556339e
Author: Dave Goehrig <dave at bestpractical.com>
Date:   Tue Apr 11 15:53:47 2017 -0400

    fixing bin patch

diff --git a/bin/rt-assets-import-csv.in b/bin/rt-assets-import-csv.in
index 69ce6af..de12377 100755
--- a/bin/rt-assets-import-csv.in
+++ b/bin/rt-assets-import-csv.in
@@ -9,7 +9,7 @@ use lib qw(/opt/rt5/local/lib /opt/rt5/lib);
 
 use Getopt::Long;
 my %opt;
-GetOptions( \%opt, 'help|h', 'update|u', 'insert|i', 'debug|d', 'mdy', 'dmy', 'config|c=s' );
+GetOptions( \%opt, 'help|h', 'update|u', 'insert|i', 'debug|d', 'mdy', 'dmy', 'config|c=s', 'separator|s=s' );
 my $file = shift @ARGV;
 
 if ( $opt{help} || !$file ) {
@@ -54,6 +54,7 @@ my ( $created, $updated, $skipped ) = RT::Extension::Assets::Import::CSV->run(
     File        => $file,
     Update      => $opt{update},
     Insert      => $opt{insert},
+    Separator   => $opt{separator},
 );
 
 print <<"EOF";

commit f972edc61709ada203bc537b736d28ab76279d86
Author: Dave Goehrig <dave at bestpractical.com>
Date:   Tue Apr 4 16:16:35 2017 -0400

    Add support for specifying separator charter(s)

diff --git a/lib/RT/Extension/Assets/Import/CSV.pm b/lib/RT/Extension/Assets/Import/CSV.pm
index 29e3b04..3f259ee 100644
--- a/lib/RT/Extension/Assets/Import/CSV.pm
+++ b/lib/RT/Extension/Assets/Import/CSV.pm
@@ -20,6 +20,7 @@ sub run {
         File        => undef,
         Update      => undef,
         Insert      => undef,
+        Separator   => undef,
         @_,
     );
 
@@ -76,7 +77,7 @@ sub run {
 
     my @required_columns = ( $field2csv->{$unique ? "CF.$unique" : "id"} );
 
-    my @items = $class->parse_csv( $args{File} );
+    my @items = $class->parse_csv( $args{File}, $args{Separator} );
     unless (@items) {
         RT->Logger->warning( "No items found in file $args{File}" );
         return (0, 0, 0);
@@ -286,9 +287,10 @@ sub get_value {
 sub parse_csv {
     my $class = shift;
     my $file  = shift;
+    my $sep = shift || ',';
 
     my @rows;
-    my $csv = Text::CSV_XS->new( { binary => 1 } );
+    my $csv = Text::CSV_XS->new( { binary => 1, sep => $sep } );
 
     open my $fh, '<', $file or die "failed to read $file: $!";
     my $header = $csv->getline($fh);

-----------------------------------------------------------------------


hooks/post-receive
-- 
rt-extension-assets-import-csv


More information about the Bps-public-commit mailing list