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
https://forums.phpfreaks.com/topic/213881-parse-filename-and-contents-of-textfile/
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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.