Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Mar 2016
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PowerShell: How to split text file into multiple files by columns

    I want to split a text file<delimited by a '|' based on number of columns, but in the partitioned files all other columns should become null with headers and
    delimiter symbol intact.

    Source File
    A|B|C|D|E|F
    1|2|3|4|5|6
    |2||4|5|
    1|2||||6




    To


    File 1:
    Only Picks the data for A,B all else becomes Null<Keep the header intact in all partitioned files>
    A|B|C|D|E|F
    1|2||||
    |2||||
    1|2||||


    File 2:
    Only Picks the data for C,D all else becomes Null
    A|B|C|D|E|F
    ||3|4||
    |||4||
    |||||




    File 3:
    Only Picks the data for E,F all else becomes Null
    A|B|C|D|E|F
    ||||5|6
    ||||5|
    |||||6

  2. #2
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,207
    Thanks
    49
    Thanked 989 Times in 919 Posts

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •