Powershell, Split String

Again I cant seem to align my columns here games are fine but time and date are skewed. What is my issue this same as last time but I cant seem to put a finger on it.

My games has Dates and My date column just has a constant. when it should be a date.

CLS

# HAP available at http://htmlagilitypack.codeplex.com/
# (originally http://www.nuget.org/packages/HtmlAgilityPack)
Add-Type -path C:\pstemp\HtmlAgilityPack\Net40\htmlagilitypack.dll
#Add-Type -path C:\pstemp\HtmlAgilityPack\Net20\htmlagilitypack.dll
$Website = 'http://espn.go.com/nfl/schedule'
$wc  = New-Object System.Net.WebClient;
$doc = New-Object HtmlAgilityPack.HtmlDocument
$doc.LoadHtml($wc.DownloadString($Website))
 
$games = @()
$Allgames = @()
foreach ($day in $doc.DocumentNode.SelectNodes('//table["tablehead"]'))
{
  $rows = $day.SelectNodes('tr')
  $Week = $rows[0].InnerText -replace "back to top &#187;", ""<# [DateTime] #>

  foreach ($row in $rows[2..$rows.Count])
  {
    $col = $row.Element('td'); 
        if ($col.Attributes["class"].value -eq "colhead")
            { # a day
                    $day = $col.ChildNodes[1].InnerText
            } 

    $teams  = $col.InnerText
    $col = $col.NextSibling; 
    $time = ($col.ChildNodes[0,2] | Select -ExpandProperty InnerText) -join " at "
    $games += New-Object PsObject -Property @{Week = $week;date = $day; time = $time; Teams = $teams}
  }
}

$Allgames += $games

$Allgames | select Week,Date,time,@{Name='Games';Expression={[string]$_.Teams}} | Format-Table -AutoSize

Open in new window

LVL 8
Leo TorresSQL DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
You changes to the code of http://www.experts-exchange.com/Q_28223497.html are not correct, you should have been kept all of it, and just add the time column.
CLS

# HAP available at http://htmlagilitypack.codeplex.com/
# (originally http://www.nuget.org/packages/HtmlAgilityPack)
Add-Type -path C:\pstemp\HtmlAgilityPack\Net40\htmlagilitypack.dll
$Website = 'http://espn.go.com/nfl/schedule'
$wc  = New-Object System.Net.WebClient;
$doc = New-Object HtmlAgilityPack.HtmlDocument
$doc.LoadHtml($wc.DownloadString($Website))
 
$games = @()
$Allgames = @()
foreach ($day in $doc.DocumentNode.SelectNodes('//table["tablehead"]'))
{
  $rows = $day.SelectNodes('tr')
  $Week = $rows[0].InnerText -replace "back to top &#187;", ""<# [DateTime] #>

  foreach ($row in $rows[1..$rows.Count])
  {
    $col = $row # .Element('td'); 
    if ($col.Attributes["class"].value -eq "colhead")
    { # a day
      $day = $col.ChildNodes[1].InnerText
    } else {  # a game
      $teams = $col.ChildNodes[0].InnerText
      $time  = $col.ChildNodes[2].InnerHTML
      $games += New-Object PsObject -Property @{Week = $week;date = $day; time = $time; Teams = $teams}
    }
  }
}

$Allgames += $games

$Allgames | select Week,Date,time,@{Name='Games';Expression={[string]$_.Teams}} | Format-Table -AutoSize

Open in new window

There is only one thing left - some rows contain something like
   ·Bye: Cleveland, Kansas City, New England, NY Jets
Those rows can be detected e.g. by filtering for
  <strong>.</strong>
or the text
  Bye
or
  &middot;
as part of the InnerText. Or you keep it as is.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Leo TorresSQL DeveloperAuthor Commented:
Dont want to be much of a bother this is going to a table any way I can delete rows there.

I tried to put the time outside of loop. An failed again. but thank I need this before the 5th. Once the first game happens the page changes...

Thanks again!
0
Leo TorresSQL DeveloperAuthor Commented:
Thanks for being patient!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.