Hi Guy's can someone help me in converting the following
I have a flat text file which has several thousand lines which I need to convert to a csv it's got a consistent format but basically want every time it hit's txt to create a new line with the subsequent lines comma delimited for example
txt.1,line 1, line 2, line n
txt.2,line 1, line 2, line n
etc
The input file looks like this
txt.1
line 1
line 2
line n
txt.2
line 1
line 2
line n
txt.n
line n
>cat p1.txt
txt.1
line 1
line 2
line n
txt.2
line 1
line 2
line n
txt.n
line n
>sed 's/txt/~txt/g' <p1.txt | tr "\n" "," | tr "~" "\n" | sed 's/,$//'
txt.1 ,line 1 ,line 2 ,line n
txt.2 ,line 1 ,line 2 ,line n
txt.n ,line n