473,882 Members | 1,637 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
mi*****@feldhei m-web.de
Jul 16 '05 #1
2 23648
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($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
mi*****@feldhei m-web.de


--
MeerKat

Jul 16 '05 #2
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2169
by: adrian GREEMAN | last post by:
When I try to import a text file with new data for an existing table I get the error "1148 - the used command is not allowed with this MySQL version." I have tried with both PHPMyAdmin2.3 and with MySQLFront 2.5. Both these GUI programmes have an "import from text file" command which I have used successfully several times to add entries to this table before - running just this MySQL version. I have structured the data in the text...
0
2376
by: Mario Ohnewald | last post by:
Hello! I want to import a MySQL 3.x Databse to my new shiny MySQL4.x. I did a backup with /usr/local/mysql-standard-4.0.14-pc-linux-i686/bin/mysqldump -u root -p --opt -A > mysql_lamp_backup.`date '+%Y.%m.%d'`.sql And i tried to import it to MySQL4.x with: /usr/local/mysql/bin/mysql -u root -p < mysqlbak The error: ERROR 1064 at line 598: You have an error in your SQL syntax. Check the
7
9305
by: jj | last post by:
It's taking forever to upload 400,000 records to the database through access/odbc, and I've tried phpMyAdmin's interface but it seems to timeout during import of a CSV file. Is there a better way to import 400,000+ records?
2
9214
by: Brian Huether | last post by:
I saved my website databgase to my home computer. I am setting up a local version of the site, and need to import the database. I have mysql and everything set up. But when I try to run the sql script that I exported from my site's control panel, I get an out of memory error. What is the proper way to import this database? Do I need to increase some memory setting? -brian
2
22721
by: jet | last post by:
Hi, Maybe this is an easy task, but I'm having a really hard time figuring out how to do this. I'm a complete newbie to SQL Server. I have a database dump file from MySQL that's in .sql format. I'm trying to figure out how to import that into SQL Server 2000 so that I'll be able to manipulate it in a gui format, rather than command line. I can't find any import that takes a .sql file. I've been trying to load it into the query...
4
12728
by: news | last post by:
Our production database in an exported textfil runs about 60 MB. Compressed that's about 9 MB. I'm trying to import the export into another machine running FC3 and mySQL 11.18, and it appears as though the file may be too big! When I try to do it via command line: mysql -u root --host=localhost printing < ./printing.txt It eventually errors out with a "syntax error on line X" and only about
1
2987
by: George Develekos | last post by:
I need to import into mysql data from DB2. One of the DB2 table columns is of the TIMESTAMP type, which, unlike its MySQL counterpart, supports fractions of a second, up to 6 digits, i.e. it is of the form 2005-07-13-23:45:32.000000 ....whereas the MySQL timestamp type is of the form 2005-07-13 23:45:32
7
33428
by: phillip.s.powell | last post by:
We're looking at a GUI interface for our MySQL DB and I am interested in MySQL Administrator, however, one of our requirements is to be able to import/export databases. Is this possible or do I need to know else (e.g. Navicat)? Thanks Phil
0
3485
by: NewbieSupreme | last post by:
I'm using PHPMyAdmin on an Apache2Triad install (latest version; 5.x.x, which installs PHP5 and PHPMyAdmin 2.8 as well). In Access, I exported a table to a text file, tab-delimited, text qualifyer of "none" (this is how I read to do it from newsgroups). When I use the Query window in phpmyadmin to import the text file, it waits a while, then returns an error: #1064 - You have an error in your SQL syntax; check the manual that...
7
4204
by: Randy | last post by:
Folks: We have a web-based app that's _really_ slowing down because multiple clients are writing their own private data into a single, central database. I guess the previous programmer did things this way because it made things easy. Well, I'm the person that has to put up with the long-term headache. Anywho, someone at work wants things sped up, so what I'm looking at doing is this for each client:
0
9931
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9776
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10724
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10827
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9556
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7113
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5978
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4599
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3226
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.