i have text files containing data variable amounts of white space between values. extract data i've loaded string. i've made array of lines using componentsseparatedbystring("\n"). each element of array contains string atoms symbol, x , , z position and, molecules, radius , residue symbol. each of these sample lines element:
c 11.01600 2.60800 18.68400 1.95 t
c 9.14000 1.29600 19.60800 1.95 t
p 4.62800 -2.84000 19.21200 2.08
but need make arrays each element in big array. let's call them "subarrays". varying amount of whitespace makes difficult apply standard code know of. i've tried filling subarray using componentsseparatedbystring(" ") gets values elements burdened whitespace elements inbetween. i've tried iterating on members of subarray remove whitespace elements doesn't seem work. plus i'd rather avoid if possible considerably increase load time models , make interaction such user resizing unfeasible. of these models couple thousand lines long.
any appreciated.
let s1 = oneline.componentsseparatedbystring(" ").filter{ $0 != ""} print(s1)
where oneline 1 line of element. first array give different elements including "" , filter remove "" array , give 6 data values of line.
e.g.
var oneline = "c 11.01600 2.60800 18.68400 1.95 t" let s1 = str.componentsseparatedbystring(" ").filter{ $0 != ""}
s1 "["c", "11.01600", "2.60800", "18.68400", "1.95", "t"]\n"
Comments
Post a Comment