Jump to content

Reading TXT Files and storing it to the Database.


Bern42

Recommended Posts

Uploading the TXT file andHow to read the TXT Files and Insert it on the Database.I have posted a link of the Files i will insert on the database of the server.THE TXT FILE-Reading in boxscore text files produced from the nba live game. We need to be able to read those files and store the game and stats (TXT File) into the database.Thanks I hope someone can help thanks..

Link to comment
Share on other sites

To parse the file, you will want to use the explode function to split the file up into lines, and then go through each line and do what you need to do. If you know the second line is the team name, then you look at that line and store it in the team name variable or whatever. Since the file doesn't have any commas separating the fields, in order to parse each result line you will need to scan through the whitespace until you hit the next non-space character, and then start recording characters until you hit the next space. You will probably want to use the explode, count, and maybe strpos functions for this. The explode function separates the lines, you can use count to figure out how long the line is, and then use array syntax to access each individual character.

for ($i = 0; $i < count($current_line); $i++){  $current_char = $current_line[$i];}

Then you check the current character to see if it's a space, and decide to either add it to a variable or ignore it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...