Answer the question
In order to leave comments, you need to log in
How to remove extra characters?
Hello! There is a file with two such lines:
***ba*** *imen.* SUM^3^ Orf-9 BN F^2^ Gr Goal UNS^2^ UAS URS
**ba^1^** *vig .* SUM (*res.*) Orff-9 BN F Gr UNS UAS URS (*res.*)
I break each into 3 parts: what is in the first asterisks, what is in the second and what starts with SUM
So I remove the asterisks in the second part, since there are always two of them:
r = []
for i in file:
s = i.split(" ")[0]
o = " ".join(i.split(" ")[1:])
try:
ch = o.split("*")[1]
o = o.replace(ch,"").replace("**","")
except:
ch = None
r.append([s,ch,o])
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question