Export csv spits out length only

后端 未结 3 2034
既然无缘
既然无缘 2020-12-21 14:40

I can only get the length when exporting this to csv, how should it be done properly.

$redo = Import-CSV c:\\temp\\testimport.txt | Group-Object email |
fore         


        
3条回答
  •  有刺的猬
    2020-12-21 15:06

    The method shown for converting data to objects is a very long-hand approach, at least in my circumstance. I'm developing reports integrating with an IBM V7000 SAN storage subsystem and it's CLI, which I can call from PS using putty plink, returns either tabular output (which can be CSV) or list depending upon the query. From either I desire to export the data as CSV. From the list output I'm looping through the result set (one row = one field) and assembling the fields into a string, separating values with commas. (For the tabular output I get to skip this tedious step.)

    The following works to write the output to a CSV file which I can then open as a spreadsheet.

    $fhStream = [System.IO.StreamWriter] "20150527_QALUNTable.csv" 
    $fhStream.WriteLine($stColumnHeadings)
    $fhStream.WriteLine($stColumnValues)
    $fhStream.Close()
    

    Import-Csv works to return the input as an object that I can easily use to prepare my reports (which are assembled from many such files of output, each gathered at a separate point in time -- hence the datestamp prefix).

    There are 57 columns of data here so by converting to a CSV I avoid preparing 57 object statements.

    (Found .Net technique for writing output (fastest) at http://blogs.technet.com/b/gbordier/archive/2009/05/05/powershell-and-writing-files-how-fast-can-you-write-to-a-file.aspx)

提交回复
热议问题