dbTalk Databases Forums  

Difficulty parsing text file

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Difficulty parsing text file in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
kayda
 
Posts: n/a

Default Difficulty parsing text file - 08-23-2005 , 11:07 AM






I've been given a series of text files where all the fields are
delimted by a vertical bar, but each row takes up two rows in the text
file. So if I use any delimter like CR or LF etc., it treats each row
like two rows, since each row just finishes with a vertical bar and
then a return.

Is there any way to deal with this? I could send an example file if
required?

Thanks,
Kayda


Reply With Quote
  #2  
Old   
per.edgren@gmail.com
 
Posts: n/a

Default Re: Difficulty parsing text file - 08-23-2005 , 12:33 PM






If its a one time thing you could write a program that separates the
row so that all rows contains only one row.

Just a thought!


Reply With Quote
  #3  
Old   
kayda
 
Posts: n/a

Default Re: Difficulty parsing text file - 08-23-2005 , 12:45 PM



No, that's not an option as I'm using DTS and it is reading the files
as given to me. It reads one of these files every half hour.

Any suggestions?


Reply With Quote
  #4  
Old   
Ilya Margolin
 
Posts: n/a

Default Re: Difficulty parsing text file - 08-25-2005 , 08:44 AM



Kayda,

You best bet would be to convince the file source party you and they have no
choice, but a new clear delimiter protocol. The actual data cannot contain
delimiters. My favorite delimiters are from char(128 - 255) range. If you
positively have no choice, in theory the parsing could be done by loading
everything into a temp table with just two columns in it one being data
receptacle and the other being identity to keep the row sequence handy.
During load break rows with proposed row delimiter than parse data to adjust
the each row content, and than parse rows into real columns separating them
by the | sign. That is to me too much trouble.

Ilya

"kayda" <tabladude (AT) gmail (DOT) com> wrote

Quote:
I've been given a series of text files where all the fields are
delimted by a vertical bar, but each row takes up two rows in the text
file. So if I use any delimter like CR or LF etc., it treats each row
like two rows, since each row just finishes with a vertical bar and
then a return.

Is there any way to deal with this? I could send an example file if
required?

Thanks,
Kayda




Reply With Quote
  #5  
Old   
Thomas Bradshaw via SQLMonster.com
 
Posts: n/a

Default Re: Difficulty parsing text file - 08-25-2005 , 09:06 AM



I agree with Ilya.

It sounds like the source file has a "hard wrap" between the first/second
line pairs. When we received files in this condition, we take the following
approach in this order:

(1) Ask to have the file resubmitted without the hard-wrap. Tech-savvy
people are usually capable of handling this request. DTS can then usually
import this without problems.

(2) Preprocess (aka "scrub") the file before DTS gets it. This means using
an 'Execute Process Task' as the first step in a DTS package. You write a
quick & dirty VB app to read/scrub/write a file that DTS can then use. The
advantage here is that you can validate fields (i.e. Is 04/31 a valid date?
Is $31.9A a valid currency value?) before DTS croaks on bad data.

Good luck! Tom

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.