Python Forum
Parsing file and get a specific text
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Parsing file and get a specific text
#2
When you loop through the lines in a file like that, you will have a newline character at the end of each line. Try changing the last comparison to if txt.strip() == stop:, or setting stop = 'end\n'.

Also, file is a built-in type in Python. If you use it as a variable name, it might mess up other code that depends on it.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
Parsing file and get a specific text - by dds69 - Nov-09-2018, 10:28 AM
RE: Parsing file and get a specific text - by ichabod801 - Nov-09-2018, 02:31 PM
RE: Parsing file and get a specific text - by dds69 - Nov-12-2018, 08:06 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Text parsing Arik 5 498 Mar-11-2024, 03:30 PM
Last Post: Gribouillis
  Extracting specific file from an archive tester_V 4 588 Jan-29-2024, 06:41 PM
Last Post: tester_V
  Color a table cell based on specific text Creepy 11 2,179 Jul-27-2023, 02:48 PM
Last Post: deanhystad
Video doing data treatment on a file import-parsing a variable EmBeck87 15 3,045 Apr-17-2023, 06:54 PM
Last Post: EmBeck87
Thumbs Up Need to compare the Excel file name with a directory text file. veeran1991 1 1,173 Dec-15-2022, 04:32 PM
Last Post: Larz60+
  Reading Specific Rows In a CSV File finndude 3 1,036 Dec-13-2022, 03:19 PM
Last Post: finndude
  How to extract specific data from .SRC (note pad file) Shinny_Shin 2 1,311 Jul-27-2022, 12:31 PM
Last Post: Larz60+
  Modify values in XML file by data from text file (without parsing) Paqqno 2 1,760 Apr-13-2022, 06:02 AM
Last Post: Paqqno
  Parsing xml file deletes whitespaces. How to avoid it? Paqqno 0 1,071 Apr-01-2022, 10:20 PM
Last Post: Paqqno
  Extracting Specific Lines from text file based on content. jokerfmj 8 3,147 Mar-28-2022, 03:38 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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