The following code returns into a nice readable output.
def add_line_remove_special(ta_from,endstatus,*args,**kwargs):
try:
ta_to = ta_from.copyta(st
To get all text on a line after a underscore character, split on the first _
character and take the last element of the result:
line.split('_', 1)[-1]
This will also work for lines that do not have an underscore character on the line.
Demo:
>>> 'Grp25_QTY47 5'.split('_', 1)[-1]
'QTY47 5'
>>> 'No underscore'.split('_', 1)[-1]
'No underscore'
Translating this to your code:
import textwrap
ta_to = ta_from.copyta(status=endstatus)
with botslib.opendata(ta_from.filename,'r') as infile:
with botslib.opendata(str(ta_to.idta),'wb') as tofile:
for line in textwrap.wrap(next(infile), 640):
line = line.split('_', 1)[-1]
tofile.write(line + '\r\n')