Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...A lot of the information I've found at this site would've taken me forever if I'd have attempted to research it on my own. Thanks again."

Geography

Where in the world do Tek-Tips members come from?

Flat file source - split delimited address field to additional fields.

ChrisMarin (TechnicalUser)
22 Aug 12 12:14
A client of ours can only export data in the following .csv delimited format:

ID, Name, Company, Address, Town, County, Postcode, Country

The Address field contains anything from 1 to 5 lines of local address data separated by Carriage Return.

We need to get this data into our SQL database using SSIS on a daily basis.

I have managed to import the file as Flat File, and have successfully changed the Carriage Returns in the Address field to commas.

I now have data in the Address field that represents:

Address
"20 Test Street, Testville"
"22 Test Avenue"
"Flat 2, 41 Test Close, Testville"

I would like the data to look like:

Add1,Add2,Add3,Add4,Add5
20 Test Street,Testville,,,
22 Test Avenue,,,,
Flat 2, 41 Test Close, Testville,,
Flat 5, Test House, Test close, Test Road, Testville

I have tried using Derived Columns and the FindString and SubString commands, but I can't seem to get it to work because of the differing number of commas in each record. Sometimes there are none (second row in above examples) and sometimes more (other rows in above example).

To get the first value in the field I tried:
SUBSTRING(AddressCommas,1,(FINDSTRING(AddressCommas,",",1) - 1))

but as stated it doesn't work with the differing number of commas.

Are there any other ways I can go about this?

Note: the client has no control over the quality of their data.

fredericofonseca (IS/IT--Management)
22 Aug 12 14:20
with SSIS the easier would be to do a C# script and do the string manipulation on it, and output 1 or more columns based on your own decision - doing it with plain derived columns will be harder and performance will be slower

Or do it on a staging table on SQL - again its easy enough to create a table function to do the split

Regards

Frederico Fonseca
SysSoft Integrated Ltd
www.syssoft-int.com

FAQ219-2884: How Do I Get Great Answers To my Tek-Tips Questions?
FAQ181-2886: How can I maximize my chances of getting an answer?

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close