问题
How can I represent, or at least view, this data?
PS /home/nicholas>
PS /home/nicholas> $labs='http://www.bccdc.ca/Health-Info-Site/Documents/BCCDC_COVID19_Dashboard_Lab_Information.csv'
PS /home/nicholas>
PS /home/nicholas> $labs_csv=Invoke-RestMethod -Method Get -Uri $labs -Headers @{"Content-Type" = "text/csv"}
PS /home/nicholas>
PS /home/nicholas> $labs_csv
"Date","Region","New_Tests","Total_Tests","Positivity","Turn_Around"
2020-01-23,"BC",2,2,0,32
2020-01-23,"Fraser",0,0,0,0
2020-01-23,"Interior",0,0,0,0
...
2020-11-19,"Unknown",138,17222,0,37.4
2020-11-19,"Vancouver Coastal",2923,337615,5.12,28.5
2020-11-19,"Vancouver Island",1682,118623,1.4,12.7
PS /home/nicholas>
Manually downloading the file, then importing, works fine.
the apparent parsing error doesn't quite fit, because Import-CSV
works fine on the file. Similarly, that the file is "too long" doesn't make sense as the file which was downloaded works fine.
All else being equal, of course.
Perhaps I just need to flip a switch, else powershell will choke on the "large" file?
回答1:
$labs_csv | ConvertFrom-Csv | Format-Table
This, starting with $labs_csv as you stored it, should allow you to at least view the data. Note that the difference between ConvertFrom-Csv and Import-csv has to do with whether or not the data comes from a file.
You may or may not wish to store your data in a file.
来源:https://stackoverflow.com/questions/64969211/how-to-pipe-downloaded-csv-data-from-invoke-restmethod-to-import-csv