Home > database >  How to read specific lines from list
How to read specific lines from list

Time:08-26

I want to extract from 46th line to 1420th line from a list, not single characters in the lines. I tried for loop:

spec_lines = np.arange(45,1421)
for i in spec_lines:
    line = fp[i]
    i  = 1
    data  = line
print(data)

It returned single characters like (46th line as example) [' ', '1', '1', '0', '0', '0', ' ', 'p', 'o', 'i', 'n', 't', 's', ' ', 'o', 'f', ' ', 'a', 'c', 'c', 'e', 'l',...

However, if I do p = fp[45] it returned p as 11000 points of accel data, this is what I expected to get.

CodePudding user response:

try this:

data="".join(your_list[45:1421])
  • Related