Split line at the tab character

こ雲淡風輕ζ 提交于 2019-12-11 04:22:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!