parse filename and contents of textfile
Results 1 to 2 of 2

Thread: parse filename and contents of textfile

  1. #1
    Junior Member
    Join Date
    Sep 2010
    Posts
    1

    parse filename and contents of textfile

    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] [code] [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] [code] [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.

  2. #2
    Bug Killer
    Join Date
    Jun 2008
    Location
    Wisconsin
    Posts
    665
    Well first you you will want to read up on the filesystem's in the manual

    The functions you will want to look at are basename and pathinfo for retrieving the files name. And you will likely want to use file to parse a files rows into an array.

    And then for both the file name and file rows you will need to use explode, to get the various parts separated out.
    Some Handy Resources:
    php.net for PHP
    W3Schools.com for HTML, Javascript, and CSS
    MySQL 5 Reference Manual
    And if they all fail use the
    Top Secret Web Developer Tool

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •