Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Editting txt file
#6
or if you prefer using regex
 
import re
def split_line(line):
    pattern = r'[+-]?\d.\d{5}E[+-]\d{2}'
    regex = re.compile(pattern)
    values = regex.findall(line,11)
    result = [line[:11].strip()]
    result.extend(values)
    return result


my_line ='6000       1.28403E-03-3.24947E-03 0.00000E+00-2.26290E-02-1.19560E-02 0.00000E+00-1.06940E+00-2.67490E+00 0.00000E+00 2.95513E+01 8.39675E+00 0.00000E+00'
print(split_line(my_line))
Reply


Messages In This Thread
Editting txt file - by muhsin - Oct-13-2017, 04:41 PM
RE: Editting txt file - by wavic - Oct-13-2017, 06:28 PM
RE: Editting txt file - by buran - Oct-13-2017, 06:49 PM
RE: Editting txt file - by muhsin - Oct-13-2017, 06:56 PM
RE: Editting txt file - by buran - Oct-13-2017, 07:45 PM
RE: Editting txt file - by buran - Oct-13-2017, 07:57 PM
RE: Editting txt file - by muhsin - Oct-13-2017, 08:00 PM
RE: Editting txt file - by buran - Oct-13-2017, 08:01 PM
RE: Editting txt file - by muhsin - Oct-13-2017, 08:15 PM
RE: Editting txt file - by buran - Oct-13-2017, 08:29 PM
RE: Editting txt file - by Larz60+ - Oct-13-2017, 08:40 PM
RE: Editting txt file - by muhsin - Oct-13-2017, 08:44 PM
RE: Editting txt file - by buran - Oct-13-2017, 08:45 PM
RE: Editting txt file - by buran - Oct-13-2017, 09:15 PM
RE: Editting txt file - by muhsin - Oct-13-2017, 09:31 PM
RE: Editting txt file - by buran - Oct-13-2017, 09:37 PM
RE: Editting txt file - by buran - Oct-13-2017, 09:38 PM
RE: Editting txt file - by buran - Oct-13-2017, 09:47 PM
RE: Editting txt file - by wavic - Oct-13-2017, 10:00 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020