If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > import a csv file into multiple mysql tables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-28-09, 01:57
mustlovechocolate mustlovechocolate is offline
Registered User
 
Join Date: Feb 2009
Posts: 7
Exclamation import a csv file into multiple mysql tables

Is there any way that I can import one .csv file and then distribute its contents into multiple tables?
Reply With Quote
  #2 (permalink)  
Old 02-28-09, 20:09
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 440
create a temporary table, import your csv there and then update the multiple tables from that.
Reply With Quote
  #3 (permalink)  
Old 03-02-09, 03:57
mustlovechocolate mustlovechocolate is offline
Registered User
 
Join Date: Feb 2009
Posts: 7
thanks

Will try that and tell you if I succeed..
Reply With Quote
  #4 (permalink)  
Old 03-02-09, 07:30
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
Quote:
Will try that and tell you if I succeed
You didn't provide any feedback on your previous thread regarding malnourished children.
Reply With Quote
  #5 (permalink)  
Old 03-02-09, 23:28
mustlovechocolate mustlovechocolate is offline
Registered User
 
Join Date: Feb 2009
Posts: 7
here's the thing, my csv file has around 150++ columns which would be divided into around 30 tables in mysql..

i need to use a browse button in the site to import the csv file into mysql..

i have no idea how i'm going to do it..

sorry, its really my first time to use mysql and php...
Reply With Quote
  #6 (permalink)  
Old 03-03-09, 04:07
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
Quote:
Originally Posted by mustlovechocolate
here's the thing, my csv file has around 150++ columns which would be divided into around 30 tables in mysql..

i need to use a browse button in the site to import the csv file into mysql..

i have no idea how i'm going to do it..
You could just set up a "transfer" table with those 150 columns. Then load the CSV data directly into this table and then process the data from there.

Then for each of the tables in your database that gets it's data from the CSV file you could just insert any new records that appear in the transfer table that you don't already have. You'll probably want to do an update to existing data if their fields have changed.
Quote:
Originally Posted by mustlovechocolate
sorry, its really my first time to use mysql and php
Could you not use what ever languages you are familiar with rather than trying to implement a new system using tools you're new to?
Reply With Quote
  #7 (permalink)  
Old 03-03-09, 04:33
mustlovechocolate mustlovechocolate is offline
Registered User
 
Join Date: Feb 2009
Posts: 7
unfortunately, i can't..because its a project for school..
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On