Re: Import CVS to MySQL
"Michel Feldheim" <mfeldheim@msn. com> wrote in message
news:<biai0g$78 ajr$1@ID-192890.news.uni-berlin.de>...[color=blue]
>
> 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[/color]
Don't bother. Just LOAD DATA INFILE:
http://www.mysql.com/doc/en/LOAD_DATA.html
Cheers,
NC
Import CVS to MySQL
Collapse
This topic is closed.
X
X
-
Guest replied -
Guest repliedRe: Import CVS to MySQL
Michel Feldheim wrote:[color=blue]
> 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.[/color]
Try mysqlimport:
http://www.mysql.com/doc/en/mysqlimport.html
or phpmyadmin, which can import CSV files.
MK.
[color=blue]
> 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($filen ame, $delim=',')
> {
> $row = 0;
> $dump = array();
>
> $f = fopen ($filename,"r") ;
> $size = filesize($filen ame)+1;
> while ($data = fgetcsv($f, $size, $delim)) {
> $dump[$row] = $data;
> $row++;
> }
> fclose ($f);
>
> return $dump;
> }
> set_time_limit( 0);
> $files = read_csv("kaufh of.csv", ";");
> $text = array ("<hr><br><br>n ummer: ",
> "<br>Artike l: ",
> "<br>Beschreibu ng: ",
> "<br>Größe: ",
> "<br>Form: ",
> "<br>Nummer : ",
> "<br>Hersteller : ",
> "<br>Nummer 2: ",
> "<br>Farbe: ",
> "<br>Nummer 3: ",
> "<br>Preis: ",
> "<br>Thumb: ",
> "<br>Link: ");
>
> for ($x=0; $x<count($files ); $x++)
> {
> if ($brand="kaufho f")
> {
> array_shift($fi les);
> }
> for ($z=0; $z<count($files[$x]); $z++)
> {
>
> print ($text[$z].$files[$x][$z]."<br><br>\n ");
> }
> }
>
> --
> _______________ _______________ _______________ _
> Michel Feldheim
> michael@feldhei m-web.de
>
>[/color]
--
MeerKat
Leave a comment:
-
Import CVS to MySQL
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($filen ame, $delim=',')
{
$row = 0;
$dump = array();
$f = fopen ($filename,"r") ;
$size = filesize($filen ame)+1;
while ($data = fgetcsv($f, $size, $delim)) {
$dump[$row] = $data;
$row++;
}
fclose ($f);
return $dump;
}
set_time_limit( 0);
$files = read_csv("kaufh of.csv", ";");
$text = array ("<hr><br><br>n ummer: ",
"<br>Artike l: ",
"<br>Beschreibu ng: ",
"<br>Größe: ",
"<br>Form: ",
"<br>Nummer : ",
"<br>Hersteller : ",
"<br>Nummer 2: ",
"<br>Farbe: ",
"<br>Nummer 3: ",
"<br>Preis: ",
"<br>Thumb: ",
"<br>Link: ");
for ($x=0; $x<count($files ); $x++)
{
if ($brand="kaufho f")
{
array_shift($fi les);
}
for ($z=0; $z<count($files[$x]); $z++)
{
print ($text[$z].$files[$x][$z]."<br><br>\n ");
}
}
--
_______________ _______________ _______________ _
Michel Feldheim
michael@feldhei m-web.de
Tags: None
Leave a comment: