Converting columns to rows in a text file



  • I’m sure this is a stupid question and is easy or there is a plug in but I’m lost and wasting so much time in my work.

    I’m getting CSV files and need to change each column to a row and save in a different file which is a simple text file
    IE:-
    1,2,3,4,5,6,7,8,9
    to

    1
    2
    3
    4
    5
    6
    7
    8
    9

    Can anybody help me please



  • @Trevor-Friswell
    there are a couple of ways of attacking this issue.

    First would be to open the CSV file in a spreadsheet app, likely Excel, but Open Office would also work. This would then put each field in a separate column. Then you’d pick 1 column at a time and save the data to a txt file.

    Second method is using Notepad++ to alter the data to suit by changing the commas separating each field into a “CR/LF”. I would also include an additional line feed at the end of each row, so that subsequent editing of the data could use this to help divide up the data in the separate files. Prepending a number at the beginning of each line (1 through 9) using the blank line would allow for a new sort of the lines to put them in the “file” groups. This is only a concept and may well require adjustment as one ventures through to a solution. Given some fields might have quotes around them if they have a comma within the data can further complicate matters.

    Personally, given the small amount of information you have provided I would go with the Excel idea.

    Note I haven’t actually provided any regexes (regular expressions) as obviously the example you provided is simplified (not real). All too often we try to help users where the information is limited, only to be told by the OP that in fact they “really need to do…” or that “the real data actually looks like…”. That is extremely frustrating and wasteful of time, often it can result in throwing out the solution, going back to the drawing board and designing another solution.

    I would like to point you to our FAQ, specifically:
    https://notepad-plus-plus.org/community/topic/15739/faq-desk-request-for-help-without-sufficient-information-to-help-you
    Please read that and if needing to provide more realistic data use the formatting suggestion so that the interpreter here does NOT alter your data.

    Terry


Log in to reply