diff --git a/README.md b/README.md index 94e7a18..a1c1e98 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ Custom developed software for the League of Women Voters of West Virginia -## Format for roster -The csv file should have all fields `quoted` to avoid issues where a field may have an additional comma. If file is not shipped this way, this can easily be corrected through the editor. +## IMPORTANT: Format for roster +The csv file should have all fields `quoted` to avoid issues where a field may have an additional comma. If file is not shipped this way, this can easily be corrected through the editor. However, the regexp fails if the first column is empty `/^,/`. Until we can find a better regexp to handle this sitution, the current solution is to replace all `/^,/` with `"",` which can be done with an editor like Visual Studio Code in addition to using something like calc. ## LLAW Google Civic Information API Query version 1 Copyright (C) 2023 - by Jonathan Rosenbaum diff --git a/google-civic-api.pl b/google-civic-api.pl old mode 100644 new mode 100755 index 2f46836..700e890 --- a/google-civic-api.pl +++ b/google-civic-api.pl @@ -69,20 +69,23 @@ while ( my $line = <$fh> ) { # my @fields = split( /,/, $line ); # may be commas between those quotes - my @fields = $line =~ m/("[^"]+"|[^,]+)(?:,\s*)?/g; - ( my $leagueId = $fields[0] ) =~ s/"//g; # League + my @fields = $line =~ m/(?:,|\n|^)("(?:(?:"")*[^"]*)*"|[^",\n]*|(?:\n|$))/g; #m/("[^"]+"|[^,]+)(?:,\s*)?/g; + # print $#fields . "\n"; + ( my $leagueId = $fields[1] ) =~ s/"//g; # League ( my $firstName = $fields[4] ) =~ s/"//g; # First Name ( my $lastName = $fields[5] ) =~ s/"//g; # Last Name - ( my $status = $fields[6] ) =~ s/"//g; # Active - ( my $joinDate = $fields[9] ) =~ s/"//g; # Join Date - ( my $phone = $fields[10] ) =~ s/"//g; # Phone - ( my $email = $fields[11] ) =~ s/"//g; # Email - ( my $street = $fields[12] ) =~ s/"//g; # Street - ( my $city = $fields[13] ) =~ s/"//g; # City - ( my $state = $fields[14] ) =~ s/"//g; # State - ( my $zip = $fields[16] ) =~ s/"//g; # Zip + ( my $status = $fields[7] ) =~ s/"//g; # Active + ( my $joinDate = $fields[10] ) =~ s/"//g; # Join Date + ( my $phone = $fields[11] ) =~ s/"//g; # Phone + ( my $email = $fields[12] ) =~ s/"//g; # Email + ( my $street = $fields[13] ) =~ s/"//g; # Street + ( my $city = $fields[14] ) =~ s/"//g; # City + ( my $state = $fields[15] ) =~ s/"//g; # State + ( my $zip = $fields[17] ) =~ s/"//g; # Zip next if $street eq "Mailing Street"; - next if $leagueId !~ /^WV/; + if ( $leagueId !~ /^WV/ && $leagueId ne "LWV Of West Virginia") { + next; + } if ( $searchType ne "google" && $searchType ne "ALL" )