Quantcast
Channel: /r/powershell – How to Code .NET
Viewing all articles
Browse latest Browse all 8793

Converting a PHP table to a CSV file

$
0
0

So the Call Center has a backend setup that will generate reports of all their calls, how many they pick up, ignore, etc and it generates it to a nice little PHP page with charts and a cute little table.

What we need to do is on a weekly basis is have that table emailed to other people outside of my organization. My first idea was “Don’t we have 3 interns?”, then I picked up Learn Powershell in a Month of Lunches and decided there would be a better way. (I have since picked up the tool making one as well)

So I got it halfway working but can’t figure out the rest. As it stands now I kinda got it halfway working. I was able to get the HTML of the Table but its still in HTML. Even if I save it as a CSV Excel opens it as one big column of markup.

A workaround I thought of would just be to use powershell to replace all the <TD> and <TR> with commas and shit so excel would be able to open it correctly but there has to be a better way

################################################################### ### ### ### ### ### ### This code gets a table from a PHP site and converts it to Excel ### ### It will email it to an outside vendor. ### ### ### ### ################################################################### ##################### ### Add Variables ### ##################### $URL = "http://webdev.youdontknowwhereiwork/phones/index.php" $DATA = Invoke-WebRequest -Uri $URL $OutputFile = "P:Tables.csv" ################ ### Get URL ### ################ Invoke-WebRequest -Uri $URL ################# ### Get Table ### ################# @($data.ParsedHtml.getElementsByTagName("table"))[0].OuterHTML 

I have been playing around with

Tee-Object -Variable $OutputFile | Export-CSV -Path $OutputFile 

And can’t get it to work. Once I get this worked I want to figure out the email part myself.

submitted by /u/RebootTheServer
[link] [comments]

The post Converting a PHP table to a CSV file appeared first on How to Code .NET.


Viewing all articles
Browse latest Browse all 8793