Recent

Author Topic: Reading multiple data from a TMemo  (Read 15686 times)

madref

  • Hero Member
  • *****
  • Posts: 949
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Reading multiple data from a TMemo
« on: March 26, 2019, 01:04:03 pm »
I have this file which I load in to a Tmemo-field to then extract certain data from it (See attachment)

As you can see it's a lot of text. But I manage to extract the Score for Team A & B and the Penalties Team A & B with multiple variants of this code.
Code: Pascal  [Select][+][-]
  1.       i := FindMemoLineNumber (Memo_Sheet, 'Score A', i+1);
  2.       j := StrToIntDef (Memo_Sheet.Lines[i+2],0);
  3.       Edit_GTA_P1.Text := j.ToString;
  4.       j := StrToIntDef (Memo_Sheet.Lines[i+3],0);
  5.       Edit_GTA_P2.Text := j.ToString;
  6.       j := StrToIntDef (Memo_Sheet.Lines[i+4],0);
  7.       Edit_GTA_P3.Text := j.ToString;
  8.       j := StrToIntDef (Memo_Sheet.Lines[i+5],0);
  9.       Edit_GTA_P4.Text := j.ToString;
But now comes the hard part extracting the given penalties in min per Team per period.
Has any one some good suggestions?


This topic is related
« Last Edit: April 02, 2019, 05:31:35 am by madref »
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 3.99 (rev main_3_99-649-ge13451a5ab) FPC 3.3.1 x86_64-darwin-cocoa
Mac OS X Monterey

six1

  • Full Member
  • ***
  • Posts: 117
Re: Reading multiple data from a TMemo
« Reply #1 on: March 26, 2019, 01:52:32 pm »
if i understood right...
Code: Pascal  [Select][+][-]
  1.  i := FindMemoLineNumber (Memo_Sheet, 'Penalties A', i+1);
  2.       j := StrToIntDef (Memo_Sheet.Lines[i+2],0);
  3.       Edit_GTA_P1.Text := j.ToString;
  4.       j := StrToIntDef (Memo_Sheet.Lines[i+3],0);
  5.       Edit_GTA_P2.Text := j.ToString;
  6.       j := StrToIntDef (Memo_Sheet.Lines[i+4],0);
  7.       Edit_GTA_P3.Text := j.ToString;
  8.       j := StrToIntDef (Memo_Sheet.Lines[i+5],0);
  9.       Edit_GTA_P4.Text := j.ToString;
  10.  

madref

  • Hero Member
  • *****
  • Posts: 949
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: Reading multiple data from a TMemo
« Reply #2 on: March 26, 2019, 02:13:01 pm »
No you are wrong.
it's about these instances:
Code: [Select]
1e periode
00:00: Goalie voor Alcmaria Flames Alkmaar U14 Wit: 33: Ryan BARTLETT
00:00: Goalie voor UNIS Flyers Heerenveen U14: 8: Thijs BIJLSMA
04:13: 0-1 UNIS Flyers Heerenveen U14: 13:  Gys VOLLMANN [EQ]
11:14: 0-2 UNIS Flyers Heerenveen U14: 13:  Gys VOLLMANN [EQ]
11:53: 0-3 UNIS Flyers Heerenveen U14: 66:  Sebas BRUIN (17:  Luna JONGSMA) [EQ]
15:12: 1-3 Alcmaria Flames Alkmaar U14 Wit: 21:  Sem MEIJER (37:  Casper DESPOMARE) [EQ]
16:00: PEN UNIS Flyers Heerenveen U14: 82: Patrick MEIJER 2 min Interference
18:06: 2-3 Alcmaria Flames Alkmaar U14 Wit: 37:  Casper DESPOMARE (66:  Mats MESER; 88:  Paul van den BRINK) [EQ]19:51: PEN UNIS Flyers Heerenveen U14: 10: Liam BOS 2 min Interference


Code: [Select]
24:16: PEN UNIS Flyers Heerenveen U14: PEN-S (12: Roos KARST Hooking)
27:04: PEN UNIS Flyers Heerenveen U14: 82: Patrick MEIJER 2 min Roughing
27:04: PEN Alcmaria Flames Alkmaar U14 Wit: 51: Eino NIJBOER 2 min Roughing
35:16: PEN UNIS Flyers Heerenveen U14: 10: Liam BOS 2 min Interference
37:47: 3-3 Alcmaria Flames Alkmaar U14 Wit: 88:  Paul van den BRINK (66:  Mats MESER) [EQ]39:48: PEN Alcmaria Flames Alkmaar U14 Wit: 55: Maxime GEHENIAU 2 min Slashing
Code: [Select]
44:38: 4-3 Alcmaria Flames Alkmaar U14 Wit: 20:  Bryn EIMERS (81:  Horaytio ROELOFSEN) [EQ]
46:12: PEN UNIS Flyers Heerenveen U14: 10: Liam BOS 2 min Tripping
47:12: 5-3 Alcmaria Flames Alkmaar U14 Wit: 66:  Mats MESER (88:  Paul van den BRINK) [PP]
47:36: PEN UNIS Flyers Heerenveen U14: 10: Liam BOS 2 min Slashing
47:36: PEN UNIS Flyers Heerenveen U14: HC: Lenneart SCHEENSTRA 2 min Delaying the Game
50:20: PEN UNIS Flyers Heerenveen U14: 82: Patrick MEIJER 2 min Charging
54:24: PEN Alcmaria Flames Alkmaar U14 Wit: 21: Sem MEIJER 2 min Roughing
54:24: PEN Alcmaria Flames Alkmaar U14 Wit: 21: Sem MEIJER 20 min Roughing
54:24: PEN Alcmaria Flames Alkmaar U14 Wit: 21: Sem MEIJER 10 min Roughing
54:24: PEN UNIS Flyers Heerenveen U14: 66: Sebas BRUIN 25 min Roughing
54:24: PEN UNIS Flyers Heerenveen U14: 66: Sebas BRUIN 20 min Roughing
54:24: PEN UNIS Flyers Heerenveen U14: 66: Sebas BRUIN 5 min Roughing
59:26: 6-3 Alcmaria Flames Alkmaar U14 Wit: 37:  Casper DESPOMARE [PP]59:34: PEN UNIS Flyers Heerenveen U14: 16: Nick  van den BOS 2 min Boarding
« Last Edit: March 26, 2019, 02:30:03 pm by madref »
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 3.99 (rev main_3_99-649-ge13451a5ab) FPC 3.3.1 x86_64-darwin-cocoa
Mac OS X Monterey

six1

  • Full Member
  • ***
  • Posts: 117
Re: Reading multiple data from a TMemo
« Reply #3 on: March 26, 2019, 02:22:24 pm »
ok, got it...

you have to search for: "Voortgang:"
following lines are sperated by LF  until line is CR LF or line string = "" and only LF


Voortgang:LF
1e periodeLF
00:00: Goalie voor Tilburg Trappers U14: 39: Mendo  van DIJKLF
00:00: Goalie voor Alcmaria Flames Alkmaar U14 Wit: 33: Ryan BARTLETTLF
03:50: 0-1 Tilburg Trappers U14: 5:  Chris BEEKMAN (12:  Niels van ZANTBEEK; 84:  Kalle KAPTEIN) [EQ]LF
13:18: 0-2 Tilburg Trappers U14: 12:  Niels van ZANTBEEK (5:  Chris BEEKMAN; 84:  Kalle KAPTEIN) [EQ]LF
19:39: PEN Tilburg Trappers U14: 39: Mendo  van DIJK 2 min TrippingLF
LF
LF
CR LF
« Last Edit: March 26, 2019, 02:24:37 pm by six1 »

madref

  • Hero Member
  • *****
  • Posts: 949
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: Reading multiple data from a TMemo
« Reply #4 on: March 26, 2019, 02:31:25 pm »
I can search for '2 min' but then I also have to teach for the corresponding team and that makes it difficult

You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 3.99 (rev main_3_99-649-ge13451a5ab) FPC 3.3.1 x86_64-darwin-cocoa
Mac OS X Monterey

six1

  • Full Member
  • ***
  • Posts: 117
Re: Reading multiple data from a TMemo
« Reply #5 on: March 26, 2019, 02:38:03 pm »
Datasource of textfile isn't that good...
Don't you get better structured data from elsewhere?

madref

  • Hero Member
  • *****
  • Posts: 949
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: Reading multiple data from a TMemo
« Reply #6 on: March 26, 2019, 02:50:02 pm »
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 3.99 (rev main_3_99-649-ge13451a5ab) FPC 3.3.1 x86_64-darwin-cocoa
Mac OS X Monterey

six1

  • Full Member
  • ***
  • Posts: 117
Re: Reading multiple data from a TMemo
« Reply #7 on: March 26, 2019, 03:04:10 pm »
...not that easy :-)

you can find start of lines by search of "Voortgang:"
following is to check, if finding pos of " min " inside the line

i.e.:
54:24: PEN UNIS Flyers Heerenveen U14: 66: Sebas BRUIN 25 min Roughing

first 6 chars are fixed for time... easy copy
54:24: PEN UNIS Flyers Heerenveen U14: 66: Sebas BRUIN 25 min Roughing

let x = reverse from " min " to " " (blank) pos


x to end of line is time in min and penalty text
54:24: PEN UNIS Flyers Heerenveen U14: 66: Sebas BRUIN 25 min Roughing

x reverse to ":" is Player Name
54:24: PEN UNIS Flyers Heerenveen U14: 66: Sebas BRUIN 25 min Roughing


maybe a way to parse content...



« Last Edit: March 26, 2019, 03:06:40 pm by six1 »

madref

  • Hero Member
  • *****
  • Posts: 949
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: Reading multiple data from a TMemo
« Reply #8 on: March 26, 2019, 03:10:56 pm »
But I am only interested in this part: 54:24: PEN UNIS Flyers Heerenveen U14: 66: Sebas BRUIN 25 min Roughing and which team
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 3.99 (rev main_3_99-649-ge13451a5ab) FPC 3.3.1 x86_64-darwin-cocoa
Mac OS X Monterey

bigeno

  • Sr. Member
  • ****
  • Posts: 266
Re: Reading multiple data from a TMemo
« Reply #9 on: March 27, 2019, 08:09:49 am »
You have team names at start. Put them to some array of record and search again file context for each name ex."Alcmaria Flames Alkmaar U14 Wit". You will get all instances with team name. Set additional marker for "periode" and you will get "2min" for every team in periode.

why not using Memo.Lines ?
« Last Edit: March 27, 2019, 08:11:20 am by bigeno »

mhelmstedt

  • Newbie
  • Posts: 4
Re: Reading multiple data from a TMemo
« Reply #10 on: March 27, 2019, 09:20:59 am »
This is the original
https://www.nijb.nl/nijbsheet.php?GameID=55675
On the bottom of that page there's a link to a report with a more suitable structure (https://www.nijb.nl/nijbsheet.php?GameID=55675&ShowGameSheet=1).
Br, Martin

madref

  • Hero Member
  • *****
  • Posts: 949
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: Reading multiple data from a TMemo
« Reply #11 on: March 27, 2019, 09:40:45 am »
I know that :)


But when you run it through the 'extractor' you get this
Code: [Select]
      TijdNrMinStrafAfOp
23:30342TRIP23:3025:30
29:26212HI-ST29:2631:26
37:17512HI-ST37:1739:17
37:34212HOOK37:3439:34
37:43812TRIP39:1741:17
45:01232CHARG45:0147:01
46:28812INTERF46:2848:28
49:18212ROUGH49:1851:18
57:29812KNEE57:2959:29
Then short it out between then number of the player (which can be a single digit or a double digit number) and the time of the minutes given for each penalty
« Last Edit: March 27, 2019, 09:42:41 am by madref »
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 3.99 (rev main_3_99-649-ge13451a5ab) FPC 3.3.1 x86_64-darwin-cocoa
Mac OS X Monterey

mhelmstedt

  • Newbie
  • Posts: 4
Re: Reading multiple data from a TMemo
« Reply #12 on: March 27, 2019, 10:00:46 am »
Isn't there an API for data retrieval available to avoid that transformation?
If not, choose a suitable "extractor". There are lots of HTML2CSV converting solutions.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Reading multiple data from a TMemo
« Reply #13 on: March 27, 2019, 05:40:26 pm »
Try the attached project, which you can adapt to your needs.

madref

  • Hero Member
  • *****
  • Posts: 949
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: Reading multiple data from a TMemo
« Reply #14 on: March 27, 2019, 07:24:59 pm »
How to adapt this so that I only have the minutes left.
Like:

Team A: ......
Penalties period 1
2
2
2
5
25
20
2


....
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 3.99 (rev main_3_99-649-ge13451a5ab) FPC 3.3.1 x86_64-darwin-cocoa
Mac OS X Monterey

 

TinyPortal © 2005-2018