per creare caricamento bulk
This commit is contained in:
37
create_json_user.pl
Executable file
37
create_json_user.pl
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/perl
|
||||
use warnings;
|
||||
use strict;
|
||||
use Getopt::Long;
|
||||
|
||||
my $import_user_json;
|
||||
my $filename;
|
||||
my $linecounter = 0;
|
||||
|
||||
GetOptions(
|
||||
"filename=s" => \$filename
|
||||
) or die("Error in command line arguments\n");
|
||||
open FILE, $filename
|
||||
or die( "Error: opening input file " . $filename . "\n" );
|
||||
|
||||
|
||||
while ( my $line = <FILE> ) {
|
||||
if ($linecounter == 0) {
|
||||
$linecounter++;
|
||||
$import_user_json = "[";
|
||||
} else {
|
||||
$import_user_json .= ",";
|
||||
}
|
||||
|
||||
my ( $fname,$lname,$username,$email,$phone,$company,$lang,$role ) = split( /,/, $line );
|
||||
chomp($role);
|
||||
$import_user_json .= '{"username": "' . $username . '","email": "' . $email . '","email_verified": true,' .
|
||||
'"app_metadata": {"roles": "' . $role . '","company": "' . $company . '"},' .
|
||||
'"user_metadata": {"firstname": "' . $fname . '","lastname": "' . $lname . '","phone": "+' . $phone . '","language": "' . $lang . '"}}' . "\n";
|
||||
}
|
||||
$import_user_json .= "]";
|
||||
close FILE;
|
||||
|
||||
|
||||
|
||||
|
||||
print $import_user_json;
|
||||
Reference in New Issue
Block a user