Strip comma, tabs, carriage returns, tabs etc from text field

I have a ver large database that I need to export to a tab delimited file for import into another system.  The problem I have is there is a note field, and others, that have commas, tabs, quotes, tabs, carraige returns etc. in it.  naturally this reaks havoc on a tab delimited file.

Is there a way to query or code against these fields to either remove them or replace them?
keschusterAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

LennyGrayCommented:
It appears that you only need to edit-out the tabs within the data elements of the table. The problem is that the tabs are your only problem. So, simply do a search and replace in each data column that contains tabs and replace the tabs with some other special character. You can then replace the special character with the tab after the export.
keschusterAuthor Commented:
I've figured this much out
UPDATE Parcel SET Parcel.[Property Name] = Replace([Property Name],Chr(13),"|")
checks for one character and replaces.  there are 4 characters I need to check for across 4 or more fields.

Instead of running 4 queries against each of the 4 fields I'd like to code tthis into a function that I could have update all of these characters via a call from one query.
Mike EghtebasDatabase and Application DeveloperCommented:
Would you want to use | instead of tab to seperate your fields.

| is not a very common character and it is located on the same key as \.

| looks like I o l but it is neither.

Mike
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

keschusterAuthor Commented:
normally I would but tab is a requirment
Mike EghtebasDatabase and Application DeveloperCommented:
Add |

Replace all unwanted ones

Replace | with tabs.
Mike EghtebasDatabase and Application DeveloperCommented:
sorry, I didn't read your post fully. You already had | in mind.
rockiroadsCommented:
Hi Mike :)

kes, I have a vba func which you could use. It is used to strip out the crap that you dont want

Public Function GetRidOfThoseNastyChars(sMemoText As String) As String

    Dim sReturn As String
    Dim x
   
    sReturn = ""
    For x = 1 To Len(sMemoText)
        If (Asc(Mid(sMemoText, x, 1)) >= 48 And Asc(Mid(sMemoText, x, 1)) < 57) Or _
        (Asc(Mid(sMemoText, x, 1)) >= 97 And Asc(Mid(sMemoText, x, 1)) < 122) Or _
        (Asc(Mid(sMemoText, x, 1)) >= 65 And Asc(Mid(sMemoText, x, 1)) < 90) Then
            sReturn = sReturn & Mid(sMemoText, x, 1)
        End If
    Next
   
    GetRidOfThoseNastyChars = sReturn

End Function



Now you can use this in a query eg

update mytable set myfield = GetRidOfThoseNastyChars(myfield)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rockiroadsCommented:
Simple solution, basically iterate thru each char in the specified string and build up a new string by accepting those 0-9, a-z or A-Z ranges only.
keschusterAuthor Commented:
That looks about what I was thinking.  How do you think this will perfom on 80k records with each record having 4 columns to be evaluated.
rockiroadsCommented:
Well only one way to find out

My personal choice would be to create the whole code in vba. Create a recordset and iterate thru that.
LennyGrayCommented:
you did not allow for spaces (Ascii 20)
keschusterAuthor Commented:
I ran the code and the speed was just fine.  I do want to modify to look for specific characters and replace them with a space.  But this is the right way to go
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.