Python Forum
Help to find a string and read the next lines
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help to find a string and read the next lines
#5
using regex as snippsat suggests should be considered.

The reason my script didn't work with entire file, is probably this:

the sample you provided had TEST.TEXT as first line. I expect that the full file doesn't have that.

I also only checked for the name line at start of file. You probably have repeated names throughout the real file.

Either of there two conditions requires changes to my code.
is this the case?
Reply


Messages In This Thread
RE: Help to find a string and read the next lines - by Larz60+ - Mar-19-2020, 09:24 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Formatting a date time string read from a csv file DosAtPython 5 1,305 Jun-19-2023, 02:12 PM
Last Post: DosAtPython
  read a text file, find all integers, append to list oldtrafford 12 3,620 Aug-11-2022, 08:23 AM
Last Post: Pedroski55
  Find and Replace numbers in String giddyhead 2 1,250 Jul-17-2022, 06:22 PM
Last Post: giddyhead
  Editing text between two string from different lines Paqqno 1 1,325 Apr-06-2022, 10:34 PM
Last Post: BashBedlam
  I want to simplify this python code into fewer lines, it's about string mandaxyz 5 2,137 Jan-15-2022, 01:28 PM
Last Post: mandaxyz
Question [SOLVED] Delete specific characters from string lines EnfantNicolas 4 2,238 Oct-21-2021, 11:28 AM
Last Post: EnfantNicolas
  [Solved] Trying to read specific lines from a file Laplace12 7 3,569 Jun-21-2021, 11:15 AM
Last Post: Laplace12
  Find string between two substrings, in a stream of data xbit 1 2,167 May-09-2021, 03:32 PM
Last Post: bowlofred
  reading lines from a string [Solved] ebolisa 14 6,427 Mar-28-2021, 08:16 PM
Last Post: perfringo
  Regular expression: cannot find 1st number in a string Pavel_47 2 2,433 Jan-15-2021, 04:39 PM
Last Post: bowlofred

Forum Jump:

User Panel Messages

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