none
Appending script output to a new column using Export-CSV RRS feed

  • Question

  • Hi,

    Is it possible to append PowerShell output to a new column instead of the same row using Export-CSV? 

    Current Output

    Col1             Col 2
    Script1Data
    Script2Data

    Desired Output

    Col1              Col2
    Script1Data   Script2Data

    Thanks

    Thursday, August 3, 2017 8:18 PM

Answers

  • Add a date and an index (1-20) to the output and open in Excel as a crosstab.  This is really the only way to do this correctly.  I tan  be scripted to do what you want but you will have to learn PowerShell and write a fairly complex script to do this.  This will require learning how to create a partitioned index and using it to generate a new object with more columns based on some naming convention.   

    There is no direct way to do this in PowerShell. We cannot write this for you.


    \_(ツ)_/


    • Edited by jrv Friday, August 4, 2017 5:33 PM
    • Proposed as answer by BOfH-666 Friday, August 4, 2017 8:12 PM
    • Marked as answer by RackHat Monday, August 7, 2017 3:09 PM
    Friday, August 4, 2017 5:33 PM

All replies

  • Append?  Not sure what you mean.  You can easily assign a value to a column.

    You need to ask a complete question.  You example is not very useful.


    \_(ツ)_/

    Thursday, August 3, 2017 8:24 PM
  • Lets say my script output csv is named stats.csv. This script is ran daily and outputs a single column of data (a set of numbers) and is appended at the end of the previous column of stats.csv. Instead of appending the output under the same column, I need the output to automatically go to a new column of stats.csv
    Friday, August 4, 2017 2:02 PM
  • Technically that makes no sense.   A CSV does not work that way.  A CSV is rows of related data.  You desire is a violation of that concept.


    \_(ツ)_/

    Friday, August 4, 2017 3:29 PM
  • The reason this is the desired output is so I can compare the numbers side by side. Each time the script runs, it outputs 20 rows of data. The next time it runs the 20 rows of data is located below in the same column. Sense this will be run on a daily basis it makes it difficult to compare side by side without manual intervention. 
    Friday, August 4, 2017 5:11 PM
  • Add a date and an index (1-20) to the output and open in Excel as a crosstab.  This is really the only way to do this correctly.  I tan  be scripted to do what you want but you will have to learn PowerShell and write a fairly complex script to do this.  This will require learning how to create a partitioned index and using it to generate a new object with more columns based on some naming convention.   

    There is no direct way to do this in PowerShell. We cannot write this for you.


    \_(ツ)_/


    • Edited by jrv Friday, August 4, 2017 5:33 PM
    • Proposed as answer by BOfH-666 Friday, August 4, 2017 8:12 PM
    • Marked as answer by RackHat Monday, August 7, 2017 3:09 PM
    Friday, August 4, 2017 5:33 PM