Wednesday, March 7, 2012

importing data from excel

I have an excel document that I need to import into a table. The format of the Excel spreadsheet has three columns:

|First Name | Last Name | Zip code|

This data is not normalized. I want to convert the data in the spreadsheet to foreign key values for two existing tables.

The table I'm importing to will contain records with a many-to-many relationship.

For example,

|John|Smith|77079

imports as:

|1|1|

Where "Smith" is the first record in the 'rep' table and "77079" is the first record in the 'zip' table.

How can I bring the data in and then convert the de-normalized data into ID values from my existing tables?

I have thousands of records that I need to do this for and want to automate the process.

Thanks for any help.
Regards,
-D-Create a staging table for the import, where you can bring in the "dirty" data from the spreadsheet. Once you've got it there, check to be sure you've got all of the users, and determine how you want to handle any that are AWOL. Do the same with zip codes. After you've got clean data, insert the appropriate rows into your production table, then you probably don't need your staging data anymore so you may decide to delete it.

-PatP

No comments:

Post a Comment