Convert xmlhttp textstream to csv

This topic contains 2 replies, has 1 voice, and was last updated by  David Zemdegs 2 years, 3 months ago.

  • Author
  • #36210

    David Zemdegs

    I'm rewriting an old vbscript to powershell.
    It uses xmlhttp to get data. It then does some fancy footwork using to convert xmlhttp.responseBody to text and then eventually to csv.
    If I look at $XmlHttp.responsetext it appears to be a text stream in the format of a csv file. Does anyone have any ideas how I can convert this text stream to a csv file please?
    David Z

  • #36213

    David Zemdegs

    Found it!

    $XmlHttp.responsetext | out-file D:\scripts\SourceFiles\r.txt
    $csv = import-csv D:\scripts\SourceFiles\r.txt

    Too simple!

  • #36293

    David Zemdegs

    Nope the above didn't work exactly
    This is what I needed to do:

    $stream = new-object -com ADODB.Stream
    $stream.type = 1 # Binary
    $stream.savetofile($rawfile,2) # 2 = overwrite existing or create new
    $stream = $nul
    $hpsd = import-csv $rawfile

You must be logged in to reply to this topic.