![]() |
How can I parse this text file and save the results in a database?
I want to take this text file:
http://phpir.com/user/files/text/lexicon.txt and in each row I want a value for the word, and the identifier (the 2 or 3 letters beside that word). How can I separate the two though if there's no delimeter? Is there a way to represent the new line as the delimeter instead? |
Is this a one-time operation, or will you be doing this over and over again in the future?
And is the junk stuff at the beginning of the file needed, or do you only want the lines that are letters? |
one time, and junk not needed.
I also noticed some words have two identifiers ex: word nn nnp I guess I could store a second in another col? |
1) I would use notepad+ to edit the text file ... cleaning it up.
Example, change all / characters to spaces change all , to spaces change all | to spaces change all \ to spaces etc. 2) Get it cleaned up so that you only have the special characters you allow, like & _ . - 3) So now you'll have a text file, each line has the characters that what you want. Some lines will have multiple spaces in between some words, but that's OK. 4) Now you'll use PHP to clean up the extra spaces. PHP Code:
That's sort of what I would do. Using Notepad+ to edit files, PHP, HTML, CSS is the best text editor. . |
| All times are GMT +1. The time now is 05:51 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.