Bern42 Posted November 9, 2006 Share Posted November 9, 2006 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 More sharing options...
justsomeguy Posted November 9, 2006 Share Posted November 9, 2006 You will need to use file_get_contents to read the contents of the text file, and then parse it up however you need to. I can't tell, because your link is not working. But you will need to parse the file, and then insert the records in the database using the mysql functions. Link to comment Share on other sites More sharing options...
Bern42 Posted November 10, 2006 Author Share Posted November 10, 2006 Download the TEXT File Sorry if the Link of the file isnt working I uploaded it again and Used different host its just a text file... How to parse a file? thanks Link to comment Share on other sites More sharing options...
justsomeguy Posted November 10, 2006 Share Posted November 10, 2006 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now