MySQL Forums
Forum List  »  CSV Storage Engine

Script that recognises the name of a column in a CSV file and matches it to the correspondent column, with the same name, in a MySql database
Posted by: Sarah Raniero
Date: May 08, 2013 08:40AM

Hi,

we are using PHP and MySql for our application.

we have many CSV files with different fields' order and some fields are empty, for example:

- CSV1 has the following fields order: name, description, date, address, phone
- CSV2 has the following fields order: address, description, name, date
- CSV3 has the following fields order: name, address

To upload these data in our database (and then online), we now need to have all the CSVs' fields always in the same order, so for example: name, descrition, phone, address, date. To do this we need to manually move the columns in the CSVs.

My question is: if the CSV files have the columns in a different order (but with the same field names), is it possible to match a CSV column to its right position in the database,
without having to edit manually the position of the columns in the CSV?

So basically a script that recognise the name of a column in a CSV file (for ex. address) and match it (and its content) to the correspondent column in our MySql database.

Many thanks,
Sarah

Options: ReplyQuote


Subject
Views
Written By
Posted
Script that recognises the name of a column in a CSV file and matches it to the correspondent column, with the same name, in a MySql database
3437
May 08, 2013 08:40AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.