SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Dec 2000
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have a ton of .dat files (text files) that are identically formatted (about 3000 of them). I want to get the information in the .dat files into a mysql database. Is there a script that will convert the info and put it into the database?

    A friend of mine gave me their files to start my site off with and I would really hate to do it all by hand.

  2. #2
    SitePoint Enthusiast
    Join Date
    Dec 2000
    Location
    USA
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There are a few good resources for this kindof stuff.

    http://www.hotscripts.com
    http://www.resourceindex.com
    Living the OO way.
    Hardware Help | Desperados!

  3. #3
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Micky what is the format of the .dat files?
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  4. #4
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If they contain SQL queries, just simply dump back into the DB using some shell scripting (for multiple file)

    mysql < file.sql
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  5. #5
    SitePoint Member
    Join Date
    Dec 2000
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The .dat files are text files. Here is an example:

    // Title

    <SectTitle> = Section Title

    <SubType> = update
    <Pick> = no
    <Popular> = no

    <AuthorName> = Name
    <AuthorEmail> = Email
    <AuthorHome> = http://whatever.com
    <ProgTitle> = Title
    <ProgStatus> = Shareware
    <ProgPlatform> = Windows 95/98
    <ProgRating> = no-rating.gif
    <ProgVersion> = 1.1
    <ProgDate> = 6-10-99
    <ProgSize> = 2.5 MB
    <ProgPrice> = ???
    <ProgImg> = noshot.gif

    [DownloadLinks]
    ftp://ftp.simtel.net/

    [ProgShortDesc]
    Blah blah

    [ProgLongDesc]
    Blah blah blah (up tp 1200 characters here)

    I have thousands of files like this, and I would like get this into a database.

    I looked at hotscripts.com and cgi-resources.com and did not see anything that applies to my situation...unless I missed it.

    Son Nguyen - I do not understand what you mean. Please explain.

  6. #6
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So this is a specific format, which was created by s.o. else. Can't use what I said.

    What I said was if the files contain only SQL queries, somthing like this:


    # Table structure
    #
    DROP TABLE IF EXISTS tb;
    CREATE TABLE tb (
    id bigint(20) unsigned DEFAULT '0' NOT NULL,
    body text NOT NULL,
    thread int(11) DEFAULT '0' NOT NULL
    );

    then you can just use the mysql command to put it back into the database.

    But with your situation, I believe you need customized programming, to read the files in, then parse which <tag>, then put in. Does the guy who created these files use DB? If so, probably he/she should have a file reader! Even if the person use flat text files, she/he should have a way to get the information back, so you might ask the guy.
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy


Bookmarks

Posting Permissions

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