473,771 Members | 2,394 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

parse CSV data sets for export to mysql with php

2 New Member
I’m running PHP MySQL (zen-cart) I’m looking for info on CSV files with data sets and how I can import these into MySQL. I found a number of topics involving simple CSV files and I tried a number of programs designed to do this but none addressing data sets and export to multiple tables (three in my case) within a MySQL database. My CSV input text file (see example below) is comprised of lines related to one-another according to their line positions. Records are separated by empty lines. I understand there is a function in PHP called fgetcsv and I wonder how this could be used to import this format data into MySQL.

1141,ORDER
1141,DATE,"2/10/2007, 7:44 PM"
1141,AMOUNT,36. 00,0.00,0.00,0. 00,36.00
1141,PAYMENT,In voice
1141,CUSTOMER," Smith, Joe","Smith Nursery",""
1141,ITEM,1,1,3 6.00,"Actinidia Hardy Kiwi Female",7

1142,ORDER
1142,DATE,"2/13…

The data is from a Palm handheld and I’d like to get the orders into the zen-cart database. I must admit that it seems I’m way over my head here… at least maybe someone could tell me if this is even possible. Thanks.
Feb 15 '07 #1
2 3089
Motoma
3,237 Recognized Expert Specialist
[php]
$handle = fopen($fileName , "r");
$lines = array();
for($i = 0; ($i < $num) && (!feof($handle) ); $i++) array_push($lin es, fgetcsv($handle ,65535));
[/php]

Those three lines should leave you with a 2 dimensional array with your entire CSV's content in it.
Feb 15 '07 #2
martha70
2 New Member
Thanks for the reply! I'll need to learn some basic PHP and try to fill in the rest of the script and I'll be back to report how it went. Those lines look promising.
Feb 15 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
11763
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a table in MySQL with the path & filename to the image. I have successfully uploaded and performed an update query on the database, but the problem I have is I cannot retain the primary key field in a variable which is then used in a SQL update...
0
6686
by: Donald Tyler | last post by:
Then the only way you can do it that I can think of is to write a PHP script to do basically what PHPMyAdmin is trying to do but without the LOCAL in there. However to do that you would need to be able to place the PHP file on the server, and I guess you probably can't do that either. Talk about catch 22... The only other way I can think of is to install MySQL on a machine you control, then import the data there using the method I...
1
1828
by: Andy | last post by:
I have a mysql db and running on RH linux , how can I export the data from the mysql db on the shell ? thx.
5
3309
by: Kajol | last post by:
Hi All, can u plz tell me how to import data from mysql to another database. & how to export data from anotherdata base to mysql Thanx for ur Advice Regards Kajol
22
7124
by: Illya Havsiyevych | last post by:
Hello How easily parse VB/VBA code by VB/VBA code ? Is any ready solutions ? Thank's, illya
7
33417
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
5
17278
by: seddy | last post by:
Hello ! I`m kinda new to it so I found this `job` very hard therefor I ask for Your help. So, the thing is... I have this XML file ( http://www.izishop.net/export.php ) which I need to open with php and read it, and insert some fields those fields on my MySQL database. Well... i found some usefull informations which might help me here: (http://www.thescripts.com/forum/thread2005.html) Take that data
0
2170
by: lanesbalik | last post by:
hi all, right now i'm trying to migrate from db2 running under linux to mysql v5.1. i manage to export out the db2 structure & data into a del (ascii) file. but when i try to load the data from the del file to mysql table, it generate an error. below is the load data infile syntax i use =
3
5476
by: zhif | last post by:
Hello everybody, I am trying to export the data from DB2 database to MySQL. The command I used is db2 "export to sys_state.del of del modified coldel; select * from sys_state" But, I tried to modify the chardel to be blank, by default chardel for del is "". I tried to move it out.
0
9454
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
10260
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9910
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8933
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...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6712
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
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2850
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.