Python Forum
Split string between two different delimiters, with exceptions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Split string between two different delimiters, with exceptions
#2
I have never seen split used like this. And surprised it works at all.

Are you parsing the class or the raw data?

I would start with something simple like:
foo=rawdata.split(':')
And join or delete the list slices into appropriate vars.
Here it splits as:
['', '1', '123456', '2', 'name', '42', '3', '30', '4', '', '5', 'somerandomdata', '9', '8']
Time can be assembled as
time = foo[5]+':'+foo[6]+':'+foo[7]+':'+foo[8] for example.
Reply


Messages In This Thread
RE: Split string between two different delimiters, with exceptions - by millpond - Aug-24-2020, 08:05 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  doing string split with 2 or more split characters Skaperen 22 2,323 Aug-13-2023, 01:57 AM
Last Post: Skaperen
Sad How to split a String from Text Input into 40 char chunks? lastyle 7 1,054 Aug-01-2023, 09:36 AM
Last Post: Pedroski55
  [split] Parse Nested JSON String in Python mmm07 4 1,429 Mar-28-2023, 06:07 PM
Last Post: snippsat
  PiCamera - print exceptions? korenron 2 792 Dec-15-2022, 10:48 PM
Last Post: Larz60+
  Split string using variable found in a list japo85 2 1,238 Jul-11-2022, 08:52 AM
Last Post: japo85
  Class exceptions DPaul 1 1,259 Mar-11-2022, 09:01 AM
Last Post: Gribouillis
  Split string knob 2 1,841 Nov-19-2021, 10:27 AM
Last Post: ghoul
  is this a good way to catch exceptions? korenron 14 4,594 Jul-05-2021, 06:20 PM
Last Post: hussaind
  Delimiters - How to skip some html tags from being translate Melcu54 0 1,621 May-26-2021, 06:21 AM
Last Post: Melcu54
  Parse String between 2 Delimiters and add as single list items lastyle 5 3,288 Apr-11-2021, 11:03 PM
Last Post: lastyle

Forum Jump:

User Panel Messages

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