Python Forum
Find string between two substrings, in a stream of data
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Find string between two substrings, in a stream of data
#2
How are you reading the data? As long as you have some sort of iterator for each line, you can check each line for one of your data components.

for line in stream:
    key,value = line.rstrip().split("=")
    if "SENSOR COORDINATE" in key:
        sensor = int(value)
    elif "MEASURED RESISTANCE" in key:
        resistance = int(value)

    # Act on data here between receiving new lines...
Reply


Messages In This Thread
RE: Find string between two substrings, in a stream of data - by bowlofred - May-09-2021, 03:32 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Microphone stream manipulation Talking2442 1 2,717 Nov-19-2023, 02:08 PM
Last Post: palumanic
Question in this code, I input Key_word, it can not find although all data was exact Help me! duchien04x4 3 1,031 Aug-31-2023, 05:36 PM
Last Post: deanhystad
  EEG stream data with mne and brainfolw PaulC 0 487 Aug-22-2023, 03:17 AM
Last Post: PaulC
  get data from excel and find max/min Timmy94 1 1,107 Jul-27-2022, 08:23 AM
Last Post: Larz60+
  what will be the best way to find data in txt file? korenron 2 1,150 Jul-25-2022, 10:03 AM
Last Post: korenron
  Substitue multiple substrings in one command Pavel_47 0 829 Jul-18-2022, 01:24 PM
Last Post: Pavel_47
  Find and Replace numbers in String giddyhead 2 1,219 Jul-17-2022, 06:22 PM
Last Post: giddyhead
  Decoding a serial stream AKGentile1963 7 8,514 Mar-20-2021, 08:07 PM
Last Post: deanhystad
  Regular expression: cannot find 1st number in a string Pavel_47 2 2,407 Jan-15-2021, 04:39 PM
Last Post: bowlofred
  Using lambdas and map() to parse substrings in a single line Drone4four 5 3,044 Sep-20-2020, 10:38 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

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