User:Zaz/FeedDumHostTests2/script: Difference between revisions

From LoadingReadyWiki
Jump to navigationJump to search
Zaz (talk | contribs)
Created page with "This powershell script generated User:Zaz/FeedDumHostTests2 <pre>curl "http://wiki.loadingreadyrun.com/index.php?title=Feed_Dump&action=edit" -o tmp.txt $datatable = (gc..."
 
Zaz (talk | contribs)
No edit summary
Line 19: Line 19:
$hostlist = $datatable.cohosts | select -unique | sort
$hostlist = $datatable.cohosts | select -unique | sort


$outstr = "<small>{| class=""wikitable"" border=""1""`r`n|+ Feed dump Appearances by Actor`r`n!`r`n"
$outstr = "<small>`r`n{| class=""wikitable"" border=""1""`r`n|+ Feed dump Appearances by Actor`r`n!`r`n"




Line 38: Line 38:
$colhost = $_
$colhost = $_
$outstr += "||`r`n"
$outstr += "||`r`n"
$line ="";
$datatable | %{
$datatable | %{
$episode = $_
$episode = $_
$line ="";
if( $episode.allhosts.contains( $rowhost ) -and $episode.allhosts.contains( $colhost ) )
if( $episode.allhosts.contains( $rowhost ) -and $episode.allhosts.contains( $colhost ) )
{
{
$line += "[[$($episode.name)|$($episode.number)]], "
$trimname = $episode.name.trim("[]")
$line += "[[$($trimname)|$($episode.number)]], "
}
}
$outstr += ($line.trim(", "))
$outstr += "`r`n"
}
}
$outstr += ($line.trim(", "))
$outstr += "`r`n"
}
}
     $colcount++
     $colcount++
Line 53: Line 54:
    
    
   $rowcount++;
   $rowcount++;
echo $rowcount
}
}


$outstr += "|}</small>"
$outstr += "|}`r`n</small>"


$outstr | sc "output.txt" -encoding UTF8</pre>
$outstr | sc "output.txt" -encoding UTF8</pre>

Revision as of 19:19, 11 May 2015

This powershell script generated User:Zaz/FeedDumHostTests2

curl "http://wiki.loadingreadyrun.com/index.php?title=Feed_Dump&action=edit" -o tmp.txt
$datatable = (gc tmp.txt -encoding UTF8) | ?{ $_.startswith("| ")} | ?{ !$_.startswith("| style") } | %{
  $spl = $_ -split "\|\|"
  $number = $spl[0].substring(2).trim()
  $name = $spl[1].substring(26).trim()
  $h = $spl[2].trim()
  $cohosts = $spl[3].trim() -split "\[\[" | select  -skip 1 | %{ $_ -split "\]\]|\|" | select -first 1 }

New-Object psobject | Add-Member -PassThru -MemberType NoteProperty -Name Number -Value $number `
  | Add-Member -PassThru -MemberType NoteProperty -Name Name -Value $name `
  | Add-Member -PassThru -MemberType NoteProperty -Name CoHosts -Value $cohosts `
  | Add-Member -PassThru -MemberType NoteProperty -Name AllHosts -Value ($h+$cohosts) `
  | Add-Member -PassThru -MemberType NoteProperty -Name Host -Value $h

}

$hostlist = $datatable.cohosts | select -unique | sort

$outstr = "<small>`r`n{| class=""wikitable"" border=""1""`r`n|+ Feed dump Appearances by Actor`r`n!`r`n"


$hostlist | %{ $outstr += "!scope=""col"" width=""45""| [[$($_)]]`r`n" }

$rowcount = 0
$hostlist | %{
  $rowhost = $_
  $outstr += "|-`r`n! [[$rowhost]]`r`n"
  $colcount = 0
  $hostlist | %{
    if( $colcount -eq $rowcount )
	{
		$outstr += "|bgcolor=""gray""|`r`n"
	}
	else
	{
		$colhost = $_
		$outstr += "||`r`n"
		$line ="";
		$datatable | %{
			$episode = $_
			if( $episode.allhosts.contains( $rowhost ) -and $episode.allhosts.contains( $colhost ) )
			{
				$trimname = $episode.name.trim("[]")
				$line += "[[$($trimname)|$($episode.number)]], "
			}
		}
		$outstr += ($line.trim(", "))
		$outstr += "`r`n"
	}
    $colcount++
  }
  
  $rowcount++;
}

$outstr += "|}`r`n</small>"

$outstr | sc "output.txt" -encoding UTF8