6 my $filename = $ARGV[0];
7 my $outputfile= $ARGV[1];
9 open my $fh_input, '<', $filename or die "Cannot open $filename: $!";
10 open my $fh_output, '>', $outputfile or die "Cannot open $outputfile: $!";
12 while ( my $line = <$fh_input> ) {
15 if ( $line =~ /(.*)(\".*\")(.*)/ ) {
17 # we have seen examples of the status field containing quoted comma-delimited
18 # strings which is messing up parsing of the record data which is supposed to be
19 # comma-separated at the field level. This little block converts sections of
20 # this type of data into a single-quoted-string with a semi-colon delimiter instead.
22 my $beforeBadStr = $1;
29 $line = $beforeBadStr . $badStr . $afterBadStr ;
33 my @row = split(",", $line);
34 print $fh_output "{\"index\":{\"_index\":\"auditdata\",\"_type\":\"default\"}\n";
35 print $fh_output "{\"entityType\": \"$row[0]\", \"errorMessage\": \"$row[1]\", \"violations\": [{ \"violationTimestamp\": \"$row[2]\", \"severity\": \"$row[3]\", \"violationType\": \"$row[4]\", \"violationDetails\": { \"MISSING_REL\": \"$row[5]\", \"entityType\": \"$row[6]\", \"entityId\": { \"vdc-id\": \"$row[7]\" } }, \"category\": \"$row[8]\" }, { \"violationTimestamp\": \"$row[9]\", \"severity\": \"$row[10]\", \"violationType\": \"$row[11]\", \"violationDetails\": { \"MISSING_REL\": \"$row[12]\", \"entityType\": \"$row[13]\", \"entityId\": { \"vdc-id\": \"$row[14]\" } }, \"category\": \"$row[15]\" }]}\n";