eian@php Posted September 20, 2010 Share Posted September 20, 2010 hi to all... does anybody has an idea of parsing the filename of the textfile and its contents and insert to database.. example.. format of the filename: [date] [cod] [time] 201089 1-111 93300.txt contents of the text file: 12345 John Robinson 54321 Robert svenson the table where the information should be inserted has this fields.. name of table: logs [iD] [name] [date] [time] say for example the parsing is done..it should look like this. [iD] [name] [date] [code] [time] 12345 John Robinson 2010-8-9 1-111 9:33:00 54321 Robert Svenson 2010-8-9 1-111 9:33:000 how can i do that?? can somebody help me? thanks. Quote Link to comment Share on other sites More sharing options...
joel24 Posted September 20, 2010 Share Posted September 20, 2010 if you don't know the name of the file, you'll need to loop through the files in the directory with readdir(), there is an example on the PHP.net site then you'll need to read the information held within those files and hope the data is formatted in a way that you can pull it out... tutorial on reading txt files is here http://www.tizag.com/phpT/fileread.php *edit: posted wrong link Quote Link to comment Share on other sites More sharing options...
salathe Posted September 20, 2010 Share Posted September 20, 2010 Hi eian, please see my replies on Sitepoint. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.