Python Forum
how to extract a portion of data from text lines by python 2
Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to extract a portion of data from text lines by python 2
#3
Do all lines you are interested in starting with 'OA' or 'XB'? I'd read each line and check if starts with one of these. Split the line to get it as a list. Slice it from 1 to 5. Then using list comprehension create e new list as rid of the last two symbols of each number. Finally, join it. The for loop will get four lines of code and you are done.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Messages In This Thread
RE: how to extract a portion of data from text lines by python 2 - by wavic - Nov-29-2017, 08:39 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Is it possible to extract 1 or 2 bits of data from MS project files? cubangt 8 1,109 Feb-16-2024, 12:02 AM
Last Post: deanhystad
  Why can't it extract the data from .txt well? Melcu54 3 692 Aug-20-2023, 10:07 PM
Last Post: deanhystad
  What are these python lines for? What are tey doing? Led_Zeppelin 7 1,654 Feb-13-2023, 03:08 PM
Last Post: deanhystad
  extract only text strip byte array Pir8Radio 7 3,041 Nov-29-2022, 10:24 PM
Last Post: Pir8Radio
  python extract mg24 1 974 Nov-02-2022, 06:30 PM
Last Post: Larz60+
  Extract only certain text which are needed Calli 26 6,218 Oct-10-2022, 03:58 PM
Last Post: deanhystad
  counting lines in split data Skaperen 6 1,451 Oct-07-2022, 07:09 PM
Last Post: Skaperen
  python Extract sql data by combining below code. mg24 1 986 Oct-03-2022, 10:25 AM
Last Post: mg24
  SQL Alchemy help to extract sql data into csv files mg24 1 1,830 Sep-30-2022, 04:43 PM
Last Post: Larz60+
  How to extract specific data from .SRC (note pad file) Shinny_Shin 2 1,296 Jul-27-2022, 12:31 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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