Help with reformat/transpose word

Input File

SAFAS 6000 5
ASGAFAWQ 6022 8
SGAFAWQ 6023 7
GGC 16023 3
.
.

Output File

S 6000
A 6001
F 6002
A 6003
S 6004 
A 6022
S 6023
G 6024
A 6025
F 6026
A 6027
W 6028
Q 6029
S 6023
G 6024
A 6025
F 6026
A 6027
W 6028
Q 6029
G 16023
G 16024
C 16025
.
.

First column is the word; second column is the start position of first word in first column; third column is the total number of words in first column.

I would like to reformat/transpose all the word in first column into new line and print out it corresponding position.

Thanks again for any advice :slight_smile:

You seem to mix up rows and colums?

Any attempts/ideas/thoughts from your side?

1 Like

Hi RudiC,

Yup. You're right.
So sorry about that.

I just edit my thread.

something along these lines:

awk '{ for(i=0; i<$3; i++) print substr($1,i+1,1), $2+i}' myFile
1 Like

You didn't answer my question for your own efforts. Anyhow, try

awk '{for (i=0; i<$3; i++) print substr($1, i+1, 1), $2+i}' file
1 Like

Thanks again, R. Singh :slight_smile:

I just do a few manual checking.
It seems worked perfectly with all the different case and scenario :slight_smile:

Really many thanks for your fast advice and sharing.

---------- Post updated at 11:10 AM ---------- Previous update was at 11:06 AM ----------

Thanks, RudiC.
Sorry I fail to try with own method :frowning:

What I think at first place is split the file into two (First column at file 1 and Second column at file 2).
For first 1, do the reformat of word at column 1.
For first 2, print out the corresponding position based on start word and word length at column 1.

Paste both file together after then :frowning:
My method seems not so efficient.