Link to home
Start Free TrialLog in
Avatar of mgordon-spi
mgordon-spi

asked on

CSV Import

I am importing a csv file into my Database. It is a comma delimitered file.
I have 2 tables

tPhonebook  - ID, sBook
tContacts  -  ID, sName, sPhone, iPhonebookID

iPhonebookID is linked to ID of tPhonebook

The csv file consists of

Column 1 - Name
Column 2 - Number

Column 3, 4, 5 etc is the name of a Phonebook.

I need the import to add a phone book for every column named after column 2, it could be one or multiple columns, it is different for every row.

I then need it to add that contact to each phone book and move to the next row.

If the phone book exists already I just need to ID for iPhonebookID.
Avatar of Habib Pourfard
Habib Pourfard
Flag of New Zealand image

Would you please give us a sample record of the csv file. is it like this?

Name, Number, Col1, Col2, Col3
--------------------------------------
John, 123456, Phonebook1, NULL, NULL
John, 123456, NULL, Phonebook2, NULL
Avatar of mgordon-spi
mgordon-spi

ASKER

The csv would be like this

John, 123456, Phonebook1,  
John, 123456, Phonebook1, Phonebook2, Phonebook3,
John, 123456, Phonebook1, Phonebook2,

if there is only one phone book there is only 3 columns if there is 2 phone books there is 4 columns and so on. There would never be a null column and then a phone book column
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial