locked
Read Sets of Data From a Text File and Output to Array RRS feed

  • Question

  • I have a report that I'd like to take out of an text file and put in to an array to use as a CSV. The problem is that the text file contains inconsistent sets of data. What I need to do is turn this in to a text file where each set of data is a row of 5 columns. If a line of data is missing from a set, then it returns a blank column and puts the next line where it should be if it has data. Each set of data is separated by "!"

    Example Data:

    Line 1
    Line 2
    Line 3
    Line 4
    Line 5
    !
    Line 1
    Line 2
    Line 3
    Line 5
    !
    Line 1
    Line 4
    !

    Which ideally should output to:

    Line 1 Line 2 Line 3 Line 4 Line 5
    Line 1 Line 2 Line 3 Line 5
    Line 1 Line 4


    Is Powershell the right way to go or am I wasting my time?

    Wednesday, October 28, 2020 3:12 AM

All replies

  • Please understand that this is not a free code writing forum.  If you need a programmer to help then please consult your local paper or contact an employment agency.  This forum is professional; technicians who are trained and using scripting.  It is not a place to ask others to do free work for you.

    Please carefully review the following links to set your expectation for posting in technical forums.


    \_(ツ)_/

    Wednesday, October 28, 2020 9:10 AM
  • WiJS, task as you described right now could be simple done with powershell (or any other language like VBS, Python etc.) but my guess you have inconsistent description and you real dataset would be different. If i`m right then you need find how you can identify which line should go into which position

    The opinion expressed by me is not an official position of Microsoft

    Wednesday, October 28, 2020 10:12 AM
  • use Excel, and use pivot to analyse your data
    Wednesday, October 28, 2020 4:36 PM