1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Import .xls file into mysql db?

Discussion in 'MySQL' started by rlynch, Feb 25, 2006.

  1. #1
    is this possible?
     
    rlynch, Feb 25, 2006 IP
  2. tkluge

    tkluge Peon

    Messages:
    54
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    export the xls file with Excel to csv - format and import this csv-file with phpMyAdmin.
    But - this only works if the format matches.
    More details will help us to give you better / more tipps.

    Best regards,
    Tobias
     
    tkluge, Feb 25, 2006 IP
  3. buronggoy

    buronggoy Peon

    Messages:
    204
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yes this is possible.this is very easy to do if you have this tool
    see this link:
    forums.digitalpoint.com/showthread.php?t=64150
    cheers!
     
    buronggoy, Mar 9, 2006 IP
  4. klaus2

    klaus2 Member

    Messages:
    64
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #4
    <?
     $handle = fopen("spreadsheet.csv", "r");
    
    if ($handle) { 
     $array = explode("\n", fread($handle, filesize("spreadsheet.csv"))); 
    }  $total_array = count($array);
    
    $i = 0;
    
    while($i < $total_array) {
    
    $data = explode(",", $array[$i]);
    
    $sql = "SELECT * FROM `table` WHERE id='" . $data[0] . "' LIMIT 1";
    $result = mysql_query($sql);
    
    if(mysql_num_rows($result) == 0) {
    
    // Put SQL insert statement here
    
    
    }
    
    $i++;
    }
    Code (markup):
     
    klaus2, Apr 13, 2008 IP
  5. yangyang

    yangyang Banned

    Messages:
    757
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    0
    #5
    yangyang, Jan 1, 2009 IP
  6. chopsticks

    chopsticks Active Member

    Messages:
    565
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
    #6
    You do realise that this post is over 2 1/2 years old? ;)
     
    chopsticks, Jan 2, 2009 IP
  7. mudassar anwar

    mudassar anwar Well-Known Member

    Messages:
    757
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    110
    #7
    Did a google search and it comes up with this free tool which might be helpful: http://www.easyfrom.net/download/
    Reply With Quote

    yeah good tool thanx for help looking for this tool and found
    it after a big search at this forum.
     
    mudassar anwar, May 3, 2009 IP
  8. yantomulia

    yantomulia Peon

    Messages:
    57
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    yup thanks for sharing , any idea to convert from mysql into cvs file?
     
    yantomulia, May 28, 2009 IP
  9. Treat

    Treat Greenhorn

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #9
    Still helped me 2 more years later after your post
     
    Treat, Feb 14, 2011 IP
  10. erwanpia

    erwanpia Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    well 2 years later the xls2mysql converter still does the job too. Automatically converts excel data types to mysql data types. http://www.webmasterbulletin.net/xls2mysql
     
    erwanpia, May 20, 2011 IP
  11. accounthub

    accounthub Greenhorn

    Messages:
    68
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #11
    you can just use the program navicat if its just a one time thing. If its done through the website then you have to convert to csv and parse the data out of there.
     
    accounthub, Jun 6, 2011 IP
  12. unknownpray

    unknownpray Active Member

    Messages:
    3,831
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    70
    #12
    User have to parse the data is suitable columns
    One column for each filed in the data base,at each column put (")
    In the last column of each row end with ”); Next have to be inserted one column foremost of all. And in each row have to enter: INSERTO INTO `TABLE` (`field1`, `field2`, `fieldN`) VALUES( .
    Next this have to be saved like normal text file and copy & paste in MySql console
     
    unknownpray, Jun 24, 2011 IP
  13. gbucsariu

    gbucsariu Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    You can import xls file to PHP using this library:
    www.easyxls.com

    For yantomulia, you can use the same library to export as CSV file from PHP.
     
    gbucsariu, Apr 12, 2012 IP