I'm new here and have a question. I do not have that much knowledge about programming because I am just a beginner, so I'd like to have as simple answers as possible. Of course, I will try my best understanding them! Also English is not my first language. Apologies for my poor English.
The task I want to do
I have a.txt
contains 100-line data described by:
import numpy as np
b = np.arange(0.005, 0.05, 0.0001)
c = np.arange(1.5, 2.51, 0.01)
with open('a.txt','w') as f:
for a in range(1,101):
f.write('{:<3d} {:<3f} {:<3f}\n'.format(a,b[a-1],c[a-1]))
The data looks like this on a.txt:
1 0.005000 1.500000
2 0.005100 1.510000
3 0.005200 1.520000
4 0.005300 1.530000
5 0.005400 1.540000
6 0.005500 1.550000
7 0.005600 1.560000
8 0.005700 1.570000
....
97 0.014600 2.460000
98 0.014700 2.470000
99 0.014800 2.480000
100 0.014900 2.490000
Now, I want to pick and write only the 1st line through the 10th line's data into another text file, b.txt. How can I do that?
I'm dealing with a very small file for simplicity for now, but I want to do this task to a very large (like a few GB) text file in the future, so I'd like to know the way of doing the task which can also be used to deal with a huge file.
If there is any information which I do not show but is necessary, please let me know. I will add it as soon as possible.
I'd appreciate your help and your time. Thank you.
※Thank all of those who edited my post for doing that. It helped and will help me make my posts better.