1 / 13

If you came to this presentation via a web browser,

The Sister Cities Database Development Project. Importing Data from a Spreadsheet that contains Phone Numbers, ZIP Codes and other similar string data that looks like a number. If you came to this presentation via a web browser, right-click and choose “F u ll Screen” before proceeding.

joyce
Download Presentation

If you came to this presentation via a web browser,

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The Sister Cities Database Development Project Importing Data from a Spreadsheet that contains Phone Numbers, ZIP Codes and other similar string data that looks like a number If you came to this presentation via a web browser, right-click and choose “Full Screen” before proceeding. Click mouse or press space bar to continue. • This presentation was prepared by Professor Steve Ross, with the advice of other MIS Faculty, for use in MIS Classes at Western Washington University. Please contact Dr. Ross for permission to use in other settings..

  2. Wizards are Wonderful, but … Complications are not uncommon with import Wizards. The Wizard interprets the data according to the rules it has been programmed with. Sometimes that interpretation incorrect. One such problem can occur when the Excel data contains strings that look like numbers, but are not actually numbers. For example, telephone numbers or ZIP codes. The Wizard will define the phone number in the import table as a numeric field in the database table it creates. The phone numbers and the ZIP codes get corrupted in the process.

  3. Solutions to the Wizard Problem Solutions to this particular problem may include… • Exporting the data from the Excel spreadsheet to a text file (e.g. NotePad) first, then importing the data from the NotePad document, rather than directly from the spreadsheet. • Modifying the data in the Excel spreadsheet so it is clearly a string. For example, you could add “x” to the beginning of every phone number or ZIP code: X555-1234. If you modify the data, of course you must undo the alteration after the data has been imported. The following slides show how Method 1 might be implemented. For extra practice, you can try Method 2 on your own.

  4. Export the Spreadsheet • File tab – Save As command • Give the file a recognizable name, e.g., WorkersTab • Save as type: Text (Tab delimited) • If there aremultiplesheets, adialog boxwill ask if itis OK to save onlyactive sheet– click OK

  5. Import the Data • Import the data • Right-click Database name; choose Tasks; choose Import Data…; click Next > on the splash screen • Choose the Data Source (Flat File Source) and browse to locate the file  • Note thesesettings • click Next >twice

  6. Import the Data • Import the data • Choose the destination then click Next >

  7. Import the Data • Import the data • Select Source Table  • Click Edit Mappings…(see next slide)

  8. Import the Data • Import the data • Click Edit Mappings… change as req., click OK,then Next > • {on the next screen} Choose Run Package immediately; click Next > • {on the next screen} Click Finish

  9. Import the Data • Import the data • Read the report, then Close.

  10. Verify the Results • Inspect the table (right-click table name, choose Select Top 1000 Rows) • Data in expected columns • Numeric data format, ensure no loss • Character data, check for truncation

  11. Analyze Data in Import Table • Modify the SELECT query created in Step 4 … • Remove “TOP 1000” • Add functions to determine maximum length of strings and maximum value of numbers: SELECT MAX(LEN([LastName])) AS [LastName] ,MAX(LEN([FirstName])) AS [FirstName] ,MAX(LEN([MidName])) AS [MidName] ,MAX([AnnualPay1000]) AS [AnnualPay1000] ,MAX(LEN([DepartmentName])) AS [DepartmentName] ,MAX(LEN([Rank])) AS [Rank] ,MAX([BudgetAuthorityIn1000]) AS [BudgetAuthorityIn1000] ,MAX([PersonalStaff]) AS [PersonalStaff] ,MAX(LEN([MailCode])) AS [MailCode] FROM [createdbexample].[dbo].[WorkersTab]

  12. Create and Populate the Final Table As with the method demonstrated in … “ImportingData - General Case (including data with large strings and integers)” … you should then build a final table and copy the data from the temporary import table to the final table. See “ImportingData - Moving Data the Import Table to the Final Table” for details.

More Related