I’m new to this, just wondering if anyone could help 🙂
I have a file like this:
start1
12.3
13.2
15.3
end1
How do I find the string end1 and add a few lines before the string, so it looks like:
start1
12.3
13.2
15.3
NaN
NaN
end1
But the number of line added has to depend on a specific number, say 5. If it only has 3 entries between start1 and end1, the numbers of line added is 2.
It’s really not clear whether that number you mention is always something you figure out from the file contents or something you might program but try this:
and let us know of any problems.
EDIT: to add c lines if less than 5 lines exist:
or to pad up to 5 lines: