Jump to content

parse filename and contents of textfile


eian@php

Recommended Posts

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.

Link to comment
Share on other sites

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

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.