By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,614 Members | 1,680 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,614 IT Pros & Developers. It's quick & easy.

Import CVS to MySQL

P: n/a
Hi everybody,

I have some big csv-like files with 15.000 and more artikles stored in it.
They should be put into a mysql database.
I thought about PHP processing

but only the read and print of these lines using the read_csv() function as
in the attached script has a more-minutes execution time.
What would be the better solution.. a Visual Basic written import tool that
uses ODCB or a PHP using one?
How can I optimize the import or get the readout faster?

Greets T_Crusher

_____________________________________
PHP
function read_csv($filename, $delim=',')
{
$row = 0;
$dump = array();

$f = fopen ($filename,"r");
$size = filesize($filename)+1;
while ($data = fgetcsv($f, $size, $delim)) {
$dump[$row] = $data;
$row++;
}
fclose ($f);

return $dump;
}
set_time_limit(0);
$files = read_csv("kaufhof.csv", ";");
$text = array ("<hr><br><br>nummer: ",
"<br>Artikel: ",
"<br>Beschreibung: ",
"<br>Größe: ",
"<br>Form: ",
"<br>Nummer: ",
"<br>Hersteller: ",
"<br>Nummer2: ",
"<br>Farbe: ",
"<br>Nummer3: ",
"<br>Preis: ",
"<br>Thumb: ",
"<br>Link: ");

for ($x=0; $x<count($files); $x++)
{
if ($brand="kaufhof")
{
array_shift($files);
}
for ($z=0; $z<count($files[$x]); $z++)
{

print ($text[$z].$files[$x][$z]."<br><br>\n");
}
}

--
______________________________________________
Michel Feldheim
mi*****@feldheim-web.de
Jul 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Michel Feldheim wrote:
Hi everybody,

I have some big csv-like files with 15.000 and more artikles stored in it.
They should be put into a mysql database.
Try mysqlimport:
http://www.mysql.com/doc/en/mysqlimport.html

or phpmyadmin, which can import CSV files.

MK.
I thought about PHP processing

but only the read and print of these lines using the read_csv() function as
in the attached script has a more-minutes execution time.
What would be the better solution.. a Visual Basic written import tool that
uses ODCB or a PHP using one?
How can I optimize the import or get the readout faster?

Greets T_Crusher

_____________________________________
PHP
function read_csv($filename, $delim=',')
{
$row = 0;
$dump = array();

$f = fopen ($filename,"r");
$size = filesize($filename)+1;
while ($data = fgetcsv($f, $size, $delim)) {
$dump[$row] = $data;
$row++;
}
fclose ($f);

return $dump;
}
set_time_limit(0);
$files = read_csv("kaufhof.csv", ";");
$text = array ("<hr><br><br>nummer: ",
"<br>Artikel: ",
"<br>Beschreibung: ",
"<br>Größe: ",
"<br>Form: ",
"<br>Nummer: ",
"<br>Hersteller: ",
"<br>Nummer2: ",
"<br>Farbe: ",
"<br>Nummer3: ",
"<br>Preis: ",
"<br>Thumb: ",
"<br>Link: ");

for ($x=0; $x<count($files); $x++)
{
if ($brand="kaufhof")
{
array_shift($files);
}
for ($z=0; $z<count($files[$x]); $z++)
{

print ($text[$z].$files[$x][$z]."<br><br>\n");
}
}

--
______________________________________________
Michel Feldheim
mi*****@feldheim-web.de


--
MeerKat

Jul 16 '05 #2

P: n/a
"Michel Feldheim" <mf*******@msn.com> wrote in message
news:<bi************@ID-192890.news.uni-berlin.de>...

I have some big csv-like files with 15.000 and more artikles stored in it.
They should be put into a mysql database.
I thought about PHP processing


Don't bother. Just LOAD DATA INFILE:

http://www.mysql.com/doc/en/LOAD_DATA.html

Cheers,
NC
Jul 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.