Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88835

Options for parsing a text file to columns

$
0
0

I am looking for some input and possible example for parsing a text file with the following format: (sorry not sure how to retain the formatting of the file in this text)

NAME          ID         FORMAT         SHORT NAME  
    DESCRIPTION (this field is on the second row an indented by 5 spaces)

The first row (NAME, ID, FORMAT and SHORT NAME) always consist of just one row. The DESCRIPTION text may span multiple rows. In some cases, there is only a first row of NAME, ID, etc. without a corresponding DESCRIPTION row.

Here is an example of how the data looks in the file now:

NAME          ID         FORMAT         SHORT NAME  
    DESCRIPTION
ABC          01          xx           AB
    abcdefg
    hijklm
    nopqrs
DEF          02          xx           DE
    abcedfg
    hijklmnopqrst
GHI          03          xx.x         GH
JKL          001         xx           JKL
    abcdef
    ghijk
    lmnopq
    rstu
    vwxyz

I would like to parse out the NAME, ID, FORMAT, SHORT NAME and DESCRIPTION into 5 separate columns in a csv or excel file for additional analysis. I don't care if the DESCRIPTION field is broken across multiple lines but it can also be concatenated into a single longer string.

Hope this all makes sense. Thanks in advance!


Viewing all articles
Browse latest Browse all 88835

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>