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\":\"topographicalsearchindex-localhost\",\"_type\":\"default\"}\n";
35 print $fh_output "{\"pkey\": \"$row[0]\", \"entityType\": \"$row[1]\", \"location\" : {\"lat\": \"$row[3]\", \"lon\": \"$row[2]\"}, \"selfLink\": \"$row[4]\"}\n";