SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    spreadsheet to mysql

    Is there a way to take a spreadsheet and import it into a mysql database?


    thanx

  2. #2
    SitePoint Addict manipura's Avatar
    Join Date
    Apr 2001
    Location
    Calgary,AB
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know the step by step instructions, but I have done it before with a spreadsheet, it had 400 lines and 14 colums. It took me awhile to get it prepared to dump into a database,

    But if you can export that spreadsheet into a text file then there ya go! Go to mysql.com and look for "LOAD DATA INFILE" that should explain it

  3. #3
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You either need to create a custom PHP script to parse a tab (or whatever) delimited file and insert each row into the database, or you can use phpMyAdmin. I highly recommend using a custom script, since phpMyAdmin can be finicky at times.
    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services

  4. #4
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is there a tutorial out there that could help me with this problem?

  5. #5
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not that I know of. If you know PHP then it's really not a problem.

    PHP Code:
    $var "1,2,3,4,6,6,7,8,9";

    $line explode("\n"$var);

    foreach(
    $line as newline){
        
    $newline explode(","$newline);
        
    $sql "INSERT INTO table SET 1='$newline[0]', 2='$newline[1]"
        
    if(!mysql_result($sql){
            echo(
    "Database Error");
            exit();
        }

    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services

  6. #6
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would try and export the spreadsheet as a CSV file (comma seperated values) and use LOAD DATA INFILE. The MySQL manual explains this well.


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
  •