Jump to content

Reading a complicated text file


Aravinthan

Recommended Posts

Hi guys,

 

Ok so here is the problem, I got 2 complicated text files, that I need to read...

 

First file(reportss.txt):

#2500

Toronto Maple Leafs 2 , New York Islanders 3

Shots: 20 - 26

TOR PP: 1 of 4 (3 shots), Passing:61/78=78 %, Challenges:33/38=84 %

NYI PP: 0 of 5 (10 shots), Passing:73/90=81 %, Challenges:40/52=75 %

Attendance: 8821 of 18819 (Air Canada Centre)

Ticket income: 279626 Match televised: No

             

 

Toronto Maple Leafs scoring.

                        ( G  A  Sh Hi Ga Ta PIM, +/-  Icetime Rating)

R Loui Eriksson          0  0  0  0  0  0    0  -2    6.00    6

R Mark Parrish            0  0  1  4  0  6    0    0  14.30    8

R Viktor Kozlov          0  0  1  0  0  0    0    0    9.00    6

R Teemu Selänne          1  1  5  0  0  0    0    0  19.20    8

C Patrik Berglund        0  0  1  0  1  0    0  -2    7.50    6

C Mike Ribeiro            0  1  1  0  0  0    4    0  20.20    7

C Stephen Weiss          0  0  1  1  0  0    0    0  15.50    6

C Stu Barnes              0  0  2  0  0  0    4    0  16.00    7

L Sean Bergenheim        0  0  1  0  0  0    0  -2    6.00    6

L Brooks Laich            0  0  0  0  1  1    0    0  16.30    6

L Niklas Hagman          0  0  2  1  1  1    0    0  16.40    7

L Jason Blake            0  1  1  0  0  0    0    0  20.50    7

D Matt Niskanen          0  0  0  1  1  0    0    0  20.00    6

D Jack Johnson            0  0  0  1  0  0    0  -1  11.10    6

D Kenny Jönsson          1  1  2  1  1  0    0  -1  27.40    8

D Jonas Frögren          0  0  0  2  0  2    0    0  15.20    7

D Willie Mitchell        0  0  2  2  0  0    0    0  19.00    7

D Sheldon Souray          0  0  2  2  0  2    2  -2  26.50    7

                        (GA,  A, Sv , PIM, +/- Icetime Rating)

G Ed Belfour              3  0  23  0    0  58.50    6

G Justin Pogge            0  0  0    0    0    0.00    0

             

New York Islanders scoring.

                        ( G  A  Sh Hi Ga Ta PIM, +/-  Icetime Rating)

R Jeremy Williams        0  0  1  0  0  0    0    0    5.20    6

R Kyle Okposo            0  0  1  0  1  0    0    1  15.10    7

R Jamal Mayers            1  1  2  2  1  0    0    1  20.40    9

R Richard Park            0  0  2  2  3  0    2    0  18.50    6

C Frans Nielsen          0  0  0  0  0  0    2    0    5.20    6

C Mark Bell              0  0  2  1  0  0    0    1  15.50    8

C Doug Weight            0  1  2  2  0  0    0    1  19.00    8

C Joe Sakic              0  0  4  0  1  0    0    0  19.50    7

L Jon Sim                0  0  1  3  0  1    2    0    5.20    7

L Andy Hilbert            1  0  1  1  0  2    0    1    8.30    7

L Ladislav Nagy          1  1  3  1  0  0    0    1  18.30    8

L Darcy Tucker            0  0  4  1  0  0    0    0  20.20    8

D Niklas Grossman        0  0  0  0  0  1    0    1    8.30    6

D Mark Streit            0  0  0  0  0  0    0    1  20.00    7

D Andy Sutton            0  0  0  1  2  1    2    0  29.20    7

D Staffan Kronwall        0  0  0  0  1  0    0    1    9.30    5

D Freddy Meyer            0  1  5  1  3  0    0    1  23.50    7

D Jay Bouwmeester        0  0  1  2  0  0    0    0  28.50    7

                        (GA,  A, Sv , PIM, +/- Icetime Rating)

G Marty Turco            2  0  18  0    0  60.00    8

G Curtis Joseph          0  0  0    0    0    0.00    0

             

Three stars of the game:

1st star: Jamal Mayers

2nd star: Ladislav Nagy

3rd star: Teemu Selänne

             

Notes for Toronto Maple Leafs:

 

Notes for New York Islanders:

 

Other notes:

 

 

###

 

Here is the second file(boxscores.txt):

#2500

12:37 0-1 NYI Jamal Mayers [1] (Ladislav Nagy, Doug Weight)

------------------------------------------------------------

31:49 0-2 NYI Ladislav Nagy [1] (Jamal Mayers, Freddy Meyer)

37:16 1-2 TOR Teemu Selänne [1] (Jason Blake, Kenny Jönsson)

------------------------------------------------------------

41:49 1-3 NYI Andy Hilbert [1])

48:49 2-3 TOR Kenny Jönsson [1] (Teemu Selänne, Mike Ribeiro)PP

------------------------------------------------------------

 

This is only the 1st data.

 

There is alot like this, so what I want to do is:

 

- Insert the 2500(gameID) in a MYSQL coloum named id

 

- Insert:

Toronto Maple Leafs 2 , New York Islanders 3
in a Mysql coloum name result

 

- Insert:

Toronto Maple Leafs scoring.

                        ( G  A  Sh Hi Ga Ta PIM, +/-  Icetime Rating)

R Loui Eriksson          0  0  0  0  0  0    0  -2    6.00    6

R Mark Parrish            0  0  1  4  0  6    0    0  14.30    8

R Viktor Kozlov          0  0  1  0  0  0    0    0    9.00    6

R Teemu Selänne          1  1  5  0  0  0    0    0  19.20    8

C Patrik Berglund        0  0  1  0  1  0    0  -2    7.50    6

C Mike Ribeiro            0  1  1  0  0  0    4    0  20.20    7

C Stephen Weiss          0  0  1  1  0  0    0    0  15.50    6

C Stu Barnes              0  0  2  0  0  0    4    0  16.00    7

L Sean Bergenheim        0  0  1  0  0  0    0  -2    6.00    6

L Brooks Laich            0  0  0  0  1  1    0    0  16.30    6

L Niklas Hagman          0  0  2  1  1  1    0    0  16.40    7

L Jason Blake            0  1  1  0  0  0    0    0  20.50    7

D Matt Niskanen          0  0  0  1  1  0    0    0  20.00    6

D Jack Johnson            0  0  0  1  0  0    0  -1  11.10    6

D Kenny Jönsson          1  1  2  1  1  0    0  -1  27.40    8

D Jonas Frögren          0  0  0  2  0  2    0    0  15.20    7

D Willie Mitchell        0  0  2  2  0  0    0    0  19.00    7

D Sheldon Souray          0  0  2  2  0  2    2  -2  26.50    7

                        (GA,  A, Sv , PIM, +/- Icetime Rating)

G Ed Belfour              3  0  23  0    0  58.50    6

G Justin Pogge            0  0  0    0    0    0.00    0

 

In home_team scoring

 

- Insert:

New York Islanders scoring.

                        ( G  A  Sh Hi Ga Ta PIM, +/-  Icetime Rating)

R Jeremy Williams        0  0  1  0  0  0    0    0    5.20    6

R Kyle Okposo            0  0  1  0  1  0    0    1  15.10    7

R Jamal Mayers            1  1  2  2  1  0    0    1  20.40    9

R Richard Park            0  0  2  2  3  0    2    0  18.50    6

C Frans Nielsen          0  0  0  0  0  0    2    0    5.20    6

C Mark Bell              0  0  2  1  0  0    0    1  15.50    8

C Doug Weight            0  1  2  2  0  0    0    1  19.00    8

C Joe Sakic              0  0  4  0  1  0    0    0  19.50    7

L Jon Sim                0  0  1  3  0  1    2    0    5.20    7

L Andy Hilbert            1  0  1  1  0  2    0    1    8.30    7

L Ladislav Nagy          1  1  3  1  0  0    0    1  18.30    8

L Darcy Tucker            0  0  4  1  0  0    0    0  20.20    8

D Niklas Grossman        0  0  0  0  0  1    0    1    8.30    6

D Mark Streit            0  0  0  0  0  0    0    1  20.00    7

D Andy Sutton            0  0  0  1  2  1    2    0  29.20    7

D Staffan Kronwall        0  0  0  0  1  0    0    1    9.30    5

D Freddy Meyer            0  1  5  1  3  0    0    1  23.50    7

D Jay Bouwmeester        0  0  1  2  0  0    0    0  28.50    7

                        (GA,  A, Sv , PIM, +/- Icetime Rating)

G Marty Turco            2  0  18  0    0  60.00    8

G Curtis Joseph          0  0  0    0    0    0.00    0

 

In away_team_scoring

 

 

- Insert this:

12:37 0-1 NYI Jamal Mayers [1] (Ladislav Nagy, Doug Weight)

------------------------------------------------------------

31:49 0-2 NYI Ladislav Nagy [1] (Jamal Mayers, Freddy Meyer)

37:16 1-2 TOR Teemu Selänne [1] (Jason Blake, Kenny Jönsson)

------------------------------------------------------------

41:49 1-3 NYI Andy Hilbert [1])

48:49 2-3 TOR Kenny Jönsson [1] (Teemu Selänne, Mike Ribeiro)PP

------------------------------------------------------------

In boxscore

 

- Insert this:

Three stars of the game:

1st star: Jamal Mayers

2nd star: Ladislav Nagy

3rd star: Teemu Selänne

 

In three_stars

 

- Insert :

Notes for Toronto Maple Leafs:

In Home_team_notes

 

Notes for New York Islanders:

in away_team_notes

 

Other notes:

in other_notes

 

And sometimes, after like 10-30 games

there is farm team results,

that appears underneath the other notes,

 

So that goes in:

farm_team_results

 

I tried to make something for almost 2 weeks now, without getting anything...

 

So it's time for me to see the experts,

 

Any help is appreciated,

 

Thanks Ara

Link to comment
Share on other sites

Sounds like you need to read the following:

 

 

file

fopen

fread

explode

 

And you might should also read about database normalization, and depending on how exactly you want to parse the data, you might also want to read:

 

preg_match and learn some basic regular expressions.

 

 

 

As far as helping you with code goes, can we see what you have so far?

Link to comment
Share on other sites

I have nothing...  :shrug:

 

I start coding but I hit a wall, and erase that try again, and I hit a wall...

 

I tought of using a code wildteen came up with, but that code uses lines to split...

 

But in this text file, the lines change from 1 game to another...

 

So that really messes me up...

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.