Talk:List of United States Representatives from Maine

From Wikipedia, the free encyclopedia
Jump to: navigation, search
          This article is of interest to the following WikiProjects:
WikiProject United States (Rated List-class, Low-importance)
WikiProject icon This article is within the scope of WikiProject United States, a collaborative effort to improve the coverage of topics relating to the United States of America on Wikipedia. If you would like to participate, please visit the project page, where you can join the ongoing discussions.
 List  This article has been rated as List-Class on the project's quality scale.
 Low  This article has been rated as Low-importance on the project's importance scale.
 
WikiProject Maine  
WikiProject icon This article is within the scope of WikiProject Maine, a collaborative effort to improve the coverage of the U.S. state of Maine on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
 ???  This article has not yet received a rating on the project's quality scale.
 ???  This article has not yet received a rating on the project's importance scale.
 
WikiProject U.S. Congress (Rated List-class, Low-importance)
WikiProject icon This article is within the scope of WikiProject U.S. Congress, a collaborative effort to improve the coverage of the United States Congress on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
 List  This article has been rated as List-Class on the project's quality scale.
 Low  This article has been rated as Low-importance on the project's importance scale.
 
This article is about one (or many) people(s).

Conversion script[edit]

I used this script to convert between the list I had copied in here before and the wikitable version. It's probably not the best I could have done, but I'm pasting it here in case anyone finds it useful.--SarekOfVulcan (talk) 15:56, 18 October 2008 (UTC)

my $infilename = "MaineReps.txt";
my $outfilename = "MaineRepsTable.txt";
 
open my $INFILE, '<', $infilename or die "Can't open input file: $!";
open my $OUTFILE, '>', $outfilename or die "Can't open output file: $!";
 
print $OUTFILE qq
	/{| class=\"wikitable\"
! Congress
! Name
! District
! Party
! Residence
! Occupation
/;
 
my %replist = {};
 
while (my $line = <$INFILE>) {
	chomp($line);
 
	my $wordchar = qr{[A-Za-z0-9.\'\&\(\)\/\,]};
	my $matchtoken = qr{$wordchar+(\s$wordchar+)*};
 
	print $OUTFILE "|-\n";
 
	print $OUTFILE "| " ;
	$lasttoken = $1;
	$line =~ /^\*(\d\d\d?\w\w\, \d{4})\s+.*/;
	if ($1 ne $lasttoken) {
		$congress = $1;
		print $OUTFILE $congress;
	}
	print $OUTFILE "\n" ;
 
	$line =~ /^\*($congress\s+|\t)($matchtoken)\s\s+.*/;
	my $rep = $2;
	$rep =~ /^([A-Za-z0-9\.\,\'\s]+)(\([^\)]+\).*)?/;
	if ($replist{$1}) {
		print $OUTFILE "| " . $rep . "\n";
	} else {
		$replist{$1} = true;
		print $OUTFILE "| [[" . $1 . "]] " . $2 . "\n";
	}
 
	$line =~ /.*\t(\d+)\s.*/; # $rep
	my $district = $1;
	print $OUTFILE "| " . $district . "\n";
 
	$line =~ /.*$district\s*\t($matchtoken)\s\s+.*/;
	my $party = $1;
	print $OUTFILE "| " . $party . "\n";
 
	$line =~ /.*$party\s*\t($matchtoken)\s\s+.*/;
	my $city = $1;
	print $OUTFILE "| " . $city . "\n";
 
	$line =~ /.*$city\s*\t($matchtoken)(\s*)$/;
	my $occupation = $1;
	print $OUTFILE "| " . $occupation . "\n";
 
}
print $OUTFILE "|}";