问题
I would like to split a line at tab and read commas as character. I tried to follow a solution of this kind, using a pos
variable containing "\t" or " ", but it returns me 0, so it doesn't find any tab. Which could be the right solution?
INTEGER :: i, dots, commas, A, T, C, G, InDel, M, Z, L, s, sf, numsize, InDelSlide, pos, base, cov
CHARACTER(len=1) :: ref
CHARACTER(len=10000) :: arg, seq, qual
CHARACTER(len=1024) :: buffer
CHARACTER(len=6) :: num
CHARACTER(len=5) chr
READ(5,'(A)') buffer
PRINT *, buffer
pos = INDEX(buffer, " ")
arg = buffer(1:pos-1)
READ(buffer(pos+1:), *) chr, base, ref, cov, seq, qual
回答1:
Tab character in Fotran is simply achar(9)
. Use
pos = INDEX(buffer, achar(9))
The achar()
function returns a character with the ASCII value you pass to it.
来源:https://stackoverflow.com/questions/40888582/split-line-at-the-tab-character