logoon  windows
Apache Lounge
Webmasters

 


About

Forum Index Downloads Search Forum Register Log in  RSS Apache Lounge


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Apache Lounge is not sponsored by anyone.

Your donations will help to keep this site alive and well, and continuing the building of the binaries.




Uploading multiple CSV files to MySQL database?

 
Post new topic   Reply to topic    Apache Forum Index -> Coding & Scripting Corner



View previous topic :: View next topic  
Author Message
kr33



Joined: 19 Sep 2006
Posts: 64
Location: South Africa

PostPosted: Mon 30 Oct '06 13:53    Post subject: Uploading multiple CSV files to MySQL database? Reply with quote

Hi,

Does anyone know how to upload multiple CSV files to a MySQL database?

I have a database setup in MySQL(i used myphpadmin), which already contains four tables.

I am developing a webpage using PHP, that needs to allow a user to upload (thus far) 8 CSV files which will be imported into the database, BUT these imports will be temporary, since i only need selected data/columns from each of the 8 CSV files. The selected columns will then be imported into the "MAIN" table, from which I extract data to draw graphs.

My question is...How do I upload these files, using PHP, temporarily so that I may extract the required data and replace the the old data/columns in the main table, the main table stores only the data needed for the graphs to be drawn. Thereafter, once I have "updated" the main table, the temporary tables can be deleted.

Please help ASAP...ANYONE!!!!

Much Thanks

Quote:
Every man has to go through hell...to reach his paradise
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 4963
Location: Germany, Next to Hamburg

PostPosted: Mon 30 Oct '06 14:35    Post subject: Reply with quote

Windows scheduler?

Better solution would be deleting the file with the script you importing the files or do you use phpmyadmin to import?

maybe you create the temporary table
CREATE TEMPORARY TABLE pn_nr SELECT personalnummer FROM `table` .....

$new = "new value";
$strSQL3 = "UPDATE `table` SET `something` ='" . $new . "' WHERE `id` = " . $id_from_csv;
Back to top
kr33



Joined: 19 Sep 2006
Posts: 64
Location: South Africa

PostPosted: Mon 30 Oct '06 15:02    Post subject: Reply with quote

I think the temporary tables would be the best option.

Do you know where I can find examples and tutorials on using temporary tables?

And I will need to replace/update WHOLE columns of data.

Any Help?

And How would I import the CSV files using actual PHP code and NOT phpmyadmin (the CSV files are comma delimited)

Thanks
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 4963
Location: Germany, Next to Hamburg

PostPosted: Mon 30 Oct '06 16:15    Post subject: Reply with quote

To import the csv file see http://pear.php.net/search.php?q=csv&in=packages&x=5&y=5

Don't know which of these two packs I used...

Quote:

And I will need to replace/update WHOLE columns of data.

Any Help?


Put the read data from csv in an array and use UPDATE to replace the data in a
while ($result = $data_from_csv){
$result['id]

.....
Back to top


Post new topic   Reply to topic    Apache Forum Index -> Coding & Scripting Corner
Page 1 of 1