Welcome to Geeklog Thursday, June 20 2013 @ 06:25 AM EDT
|
||||||||
![]() |
Forum Index > Support > Installation Support |
New Topic
|
Post Reply
|
Useful tool - CSV to MySQL |
|||
| Anonymous: droc |
|
|||||
|
|
http://csv2sql.com/
|
|||||
|
||||||
| Anonymous: Agilefuse Consulting |
|
|||||
![]() |
http://www.agilefuseconsulting.co.cc/development/csvtomysql/
this is my tool. i developed the tool using html5 and file api. please take note that this only works on firefox and google chrome browser(latest version). also large data to import requires large time to complete, and also may cause memory limit error. so please use the tool with care. thanks. |
|||||
|
||||||
| Anonymous: alexpran |
|
|||||
|
|
seems most online tools have been taken down or dont work, but found I found this basic (and free) site convertcsvtomysql.com
seems limited but was enough for my needs, i think its still in dvelopment too |
|||||
|
||||||
| Anonymous: thiyagi |
|
|||||
|
|
thanks man..
|
|||||
|
||||||
| Anonymous: Erel Segal Halevi |
|
|||||
|
|
Here is a PHP function that does the trick:
PHP Formatted Code function csv_file_to_mysql_table($source_file, $target_table, $max_line_length=10000) { if (($handle = fopen("$source_file", "r")) !== FALSE) { $columns = fgetcsv($handle, $max_line_length, ","); foreach ($columns as &$column) { $column = str_replace(".","",$column); } $insert_query_prefix = "INSERT INTO $target_table (".join(",",$columns).")\nVALUES"; while (($data = fgetcsv($handle, $max_line_length, ",")) !== FALSE) { while (count($data)<count($columns)) array_push($data, NULL); $query = "$insert_query_prefix (".join(",",quote_all_array($data)).");"; mysql_query($query); } fclose($handle); } } |
|||||
|
||||||
| Anonymous: sewerewes |
|
|||||
|
|
This function won't work unless you've got your own function for quote_all_array() - that isn't a built-in PHP function. This works pretty well:
PHP Formatted Code function quote_all_array($arr) { foreach ($arr as $k=>$v) { $returnArr[$k] = ($v) ? '"'.str_replace('"','\"',$v).'"' : "NULL" ; } return $returnArr; } |
|||||
|
||||||
| MyJuliet |
|
|||||
![]() ![]() ![]() ![]() ![]() Newbie Status: offline ![]() Registered: 08/23/11 Posts: 1 |
Please give me the correct link to your article, so I can use it. I have the same problem.
|
|||||
|
||||||
| Anonymous: Andreas Herz |
|
|||||
|
|
Hi,
maybe the phpBlocks lib can solve the export/inport of CSV files in a more smart way like Googles AppInventor. You can change the export format in an Click&Point manner. Like Google AppInventor or the programming IDE Scratch from the MIT. phpBlocks is GPL and can be downloaded from the WebSite. Worth a look for dyn. PHP formular and exports. Common Demos: http://www.freegroup.de/software/phpBlocks/demo.html Link to example: http://www.freegroup.de/test/editor/editor.php?xml=demo_sql.xml Greetings Andreas |
|||||
|
||||||
| Anonymous: Anonymous Geek |
|
|||||
|
|
For anyone wondering what was on the original mysqlDBU site... here it is in the internet archive
http://web.archive.org/web/20100912102607/http://www.sqldbu.com/eng/sections/tips/mysqlimport.html it was a web-based solution |
|||||
|
||||||
| Anonymous: Richard |
|
|||||
|
|
If you would like to pre-validate and rollback on errror - you might like check out this post/tip on CSV import from Excel to MySQL
http://leansoftware.net/tabid/123/g/posts/t/17/How-to-validate-and-upload-CSV--comma-seperated-value--data-to-a-database.aspx Could save you some time - this is a professional tool - free for 60 days |
|||||
|
||||||
| Content generated in: 0.62 seconds |
|
|
|