Jump to content
Software FX Community

Reading a remote CSV


IGSFX

Recommended Posts

- Create a script called ImportCsvWeb.ps1 with the following

$url = $args[0]
$tempFile = [system.IO.Path]::GetTempFileName()
$webClient = new-object System.Net.WebClient
$webClient.DownloadFile($url,$tempFile)
$data = import-csv $tempFile
[system.IO.File]::Delete($tempFile)
$data

- Invoke it in a powershell session (or script) as follows

.\importcsvweb.ps1 "http://<your csv file URL>" | out-chart -values <ValueColumns> -label <LabelColumn>

Note that in this case we let ImportCsvWeb to return the data without any "casting" to allow reuse of this script with multiple CSV files. You tell the out-chart cmdlet which fields should be plotted through the -values parameter (which must contain only numbers)

post-4782-13922403284035_thumb.jpg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...