Python Forum
Ignore first few letters of a line when reading file.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ignore first few letters of a line when reading file.
#1
Hello, everybody!

I have run into a spot of bother while writing my Python script and I am wondering if anyone can help me out.

I am trying to read a text file using Python. That goes well and I am able to read the file line-by-line (using the File_Object.readline() function), which is my goal. However, to make my file more organized, I do this, for example my first line:

Quote:name = John

I want to use "John" only as a variable, and I don't want to read the first 7 bytes of the line: "name = "
I only want to read "John".

Is there anyway I am able to do this? I also want to add that the variable after "name = " is randomised and may not always be "John". I just need to ignore the "name = ". Thank you.
Reply


Messages In This Thread
Ignore first few letters of a line when reading file. - by ShakeyPakey - May-29-2020, 11:14 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Good way to ignore case when searching elements? Winfried 1 339 Apr-25-2024, 12:39 PM
Last Post: menator01
  Reading and storing a line of output from pexpect child eagerissac 1 4,442 Feb-20-2024, 05:51 AM
Last Post: ayoshittu
  Copy Paste excel files based on the first letters of the file name Viento 2 559 Feb-07-2024, 12:24 PM
Last Post: Viento
Sad problems with reading csv file. MassiJames 3 790 Nov-16-2023, 03:41 PM
Last Post: snippsat
  Reading in of line not working? garynewport 2 954 Sep-19-2023, 02:22 PM
Last Post: snippsat
  Reading a file name fron a folder on my desktop Fiona 4 1,051 Aug-23-2023, 11:11 AM
Last Post: Axel_Erfurt
  Reading data from excel file –> process it >>then write to another excel output file Jennifer_Jone 0 1,212 Mar-14-2023, 07:59 PM
Last Post: Jennifer_Jone
  File "<string>", line 19, in <module> error is related to what? Frankduc 9 12,841 Mar-09-2023, 07:22 AM
Last Post: LocklearSusan
  Getting last line of each line occurrence in a file tester_V 1 945 Jan-31-2023, 09:29 PM
Last Post: deanhystad
  Reading a file JonWayn 3 1,180 Dec-30-2022, 10:18 AM
Last Post: ibreeden

Forum Jump:

User Panel Messages

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