SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2001
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    .txt databse to MySQL

    Hi,
    I have a databse in .txt format (I think it's called CVS) that my CGI script accesses, but now I have PHP and MySQL support so I would like to switch from CGI to PHP and MySQL. My databse has over 800 entries so I would rather not input each one so I am hopeing that someone knows an easy way to convert my .txt file MySQL databse.

    Before I go any further.. One of the feilds in my databse contains alot more than 255 characters (more around 1000, but it varies between entry) and from my very small tiny bit of PHP and MySQL knowlege I don't know if I can have a feild over 255 characters.

    Back to converting... It is delimited (seperated by) a "|" and has seven "feilds" for each entry. Any help is appreciated very much.

    Thanks,
    Chris
    Thanks, Chris
    -------------------------
    http://spotlyrics.com
    -------------------------

  2. #2
    SitePoint Wizard Crowe's Avatar
    Join Date
    Nov 2001
    Location
    Huntsville
    Posts
    1,117
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Your in luck. Mysql can host huge sizes. Using Blobs or Large Text. You'll want to learn how to setup your tables so that you get each field right. That's the hard part. Go to mysql.com and read up on that. Then, once you have your table done, you can use LOAD INFILE from the command line and load the text file into the mysql table of your choice.

    Or, you can cheat and use phpmyadmin from phpWizard.net . I use that quite a bit.

    Hope that helps.

    Cheers!
    Chrispian H. Burks
    Nothing To Say

  3. #3
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use the Large Text type as blob is for binary data.

    And be aware phpMyAdmin can't handle large files when importing data.
    I had a 5mg file from a forum i ran and when i tried to import it phpmyadmin puked it up at me.
    had to cut and paste small pieces of the file in one at a time.
    quite annoying.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  4. #4
    SitePoint Enthusiast
    Join Date
    Nov 2001
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanks

    I think I'll try cheating with PHPmyadmin. Thank for the quick reply...

    Chris
    Thanks, Chris
    -------------------------
    http://spotlyrics.com
    -------------------------

  5. #5
    SitePoint Zealot pnathan's Avatar
    Join Date
    Sep 2001
    Location
    Amsterdam
    Posts
    160
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have tried uploading a simple csv into MySQL using MyPHPAdmin but it is not working for me. Here are the details, this is the last hurdle in my project so I would be very grateful for any help.

    Database:
    |name |email |
    -----------------------------
    | Mathew | mathew@stuff.com |
    | Mark | mark@stuff.com |
    | Luke | luke@stuff.com |
    | John | john@stuff.com |
    -----------------------------|

    CSV file is:
    "Mathew";"mathew@stuff.com"
    "Mark";"mark@stuff.com"
    "Luke";"luke@stuff.com"
    "John";"john@stuff.com"

    Now when I try to add a textile in the above format I get the following error:


    Code:
    LOAD DATA LOCAL INFILE '/tmp/php6kAJXj' INTO TABLE `leads` FIELDS TERMINATED BY ';' ENCLOSED BY '"'
    
    MySQL said: 
    File '/tmp/phpiaYxvs' not found (Errcode: 0)
    I know that the "php6kAJXj" is the temporary name given to my file, why can it not find the file?
    I have two tickets to the Crows, sweet.


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
  •