显示标签为“parsing”的博文。显示所有博文
显示标签为“parsing”的博文。显示所有博文

2012年3月26日星期一

FlatFile Parsing Problem - Urgently Need Assistance!

We have a BIG problem that has been occurring for quite sometime. We have a RAGGED-RIGHT FFS (FlatFileSource) component which receives a FF and then transforms to XML. We define 10 FIELDS with the last field as {CRLF} per ragged right style. Simple right? The source file is sent to us from multiple separate groups, some of which don’t use the last two fields and have early line termination, so they basically are not there. The problem is that when we define X amount of fields in SSIS, it expects X amount of fields to be there. So when we receive the source file that doesn’t contain last two fields, SSIS tries to read in the next line, and in most cases successfully places the fields from the next line into the missing fields. Now what we end up with is a source file with 10 rows, but only half successfully transformed, with every other row fitted into the last two XML fields. SSIS completely ignores the {CRLF} until those specific numbers of spaces/fields have been met – even if it has to go onto the next line to get them. This seems horribly wrong to me. I would think that at the very least there should be some type of validation that prevents it from grabbing the next line. I thought that is what fixed-length SSIS style is for, and ragged right for allowing to parse multiple rows. We could enforce all clients to produce X char spaces (and we do), but there can be cases in any aspect where a file could get accidentally sent over with a shortened row. I have heard from certain individuals that SSIS adapter wasn’t designed with this in mind. Is this true, I am to believe that this would still get parsed without throwing any errors and potentially damage the ERP system it is going into? If this is the case then I feel extremely disheartened about SSIS – especially with all of the great advancements it has made.

We desperately need a workaround or at the very least some way to validate that a new row {CRLF} isn’t getting picked up in the first row of the flat file connection. Please can someone help ASAP!?

You could read the rows and then process in a script component based on your logic for handling these errors.

This is a common issue with processing flat files, and producing generic solutions. Biztalk was a real pain. If I remember from my Biztalk days a lot of the flat file parsing capabilities was driven by EDI. What you may think is logical may not suit some applications.

|||

Unfortunatelly Simon that seems to be the answer all around the board - too bad since the product was already designed (150+ DF transforms have to be modified). So do you recommend to do away with the FF Conn Mgr, and use a script source component to dynamically read in and calc the file rows? Can you perhaps provide an example of how to do what you mention?

Thanks,

|||

Haven't heard a response back, just keeping this on top - as this is a hot issue for us!

Simon (or anyone for that matter), I am interested in hearing how you would approach this, would you use a connection mgr, or use a custom src component and dynamically get in code, etc...

Thanks for helping!

|||

Have a look at the package I/ve created.

http://sqlblogcasts.com/files/3/transforms/entry409.aspx

I haven't done any type casting, or validation of field lengths just used the default 50 character column size.

|||Interesting, thanks Simon. One issue, we still need the ability to filter error rows, as the ff source allows. Can we do this using an intermediate custom transform, or must we manually create a new output for the bad rows? If the latter is the only way then do you just create a new output with columns x,m,z... and then similarly have an if/catch that would contain:

Row.Column(X,M,Z...) = extra_split_columns(col)

or, is there another function/method used to do this new output redirection?

|||

If you create an output and assoicate with the input (set the synchronous input ID to the ID of the input. That way you can redirect the row. Or you can have a seperate output where you have to copy the values from the input row to the error row.

I've updated the package http://sqlblogcasts.com/files/4/integration_services/entry412.aspx

|||Very good Simon, I think this hits the nail on the head... Thanks.

2012年3月22日星期四

Flat File Source Column Parsing Error

Hello All,

I have come across this issue with the Flat File Source when the delimiter is set to a comma.

"""KAILUA KONA,HI""","CA",

In the data snippet above and with the setting of using a comma as a column delimiter

and a " as the text qualifer.

the data will be parsed in this fashion:

"""KAILUA as a column:

HI""" as a column

CA as column

when it should be

"KAILUA,HI" as a column

CA as column.

Is there a way to let the Flat File Source to let it know not to parse the data in multiple quotes ?

Thank you

Eric Flores

The flat file parser does not know how to handle embedded qualifiers.

In this case, you can workaround this by loading the qualified data and then stripping the qualifiers in Derived Column or Script transform.

HTH.

|||

I will try that out and see if it will work. Though in my data snippet, the comma in question is not even a qualifier but is part of the data.

What I do not get is that in DTS for SQL Server 2000 when specifying a flat file as having comma as the column delimited and a double quote as the text qualifier that when given the data snippet in my previous post that it would parse the data into the correct two columns.

|||

Eric,

feel free to go to the product feedback site below and report your issue. That will create a bug in our system.

http://lab.msdn.microsoft.com/productfeedback/default.aspx

|||This has been "resolved" in product feedback. Was there a resolution or is this just the way it is going to be?

Flat File Source Column Parsing Error

Hello All,

I have come across this issue with the Flat File Source when the delimiter is set to a comma.

"""KAILUA KONA,HI""","CA",

In the data snippet above and with the setting of using a comma as a column delimiter

and a " as the text qualifer.

the data will be parsed in this fashion:

"""KAILUA as a column:

HI""" as a column

CA as column

when it should be

"KAILUA,HI" as a column

CA as column.

Is there a way to let the Flat File Source to let it know not to parse the data in multiple quotes ?

Thank you

Eric Flores

The flat file parser does not know how to handle embedded qualifiers.

In this case, you can workaround this by loading the qualified data and then stripping the qualifiers in Derived Column or Script transform.

HTH.

|||

I will try that out and see if it will work. Though in my data snippet, the comma in question is not even a qualifier but is part of the data.

What I do not get is that in DTS for SQL Server 2000 when specifying a flat file as having comma as the column delimited and a double quote as the text qualifier that when given the data snippet in my previous post that it would parse the data into the correct two columns.

|||

Eric,

feel free to go to the product feedback site below and report your issue. That will create a bug in our system.

http://lab.msdn.microsoft.com/productfeedback/default.aspx

|||This has been "resolved" in product feedback. Was there a resolution or is this just the way it is going to be?sql

2012年3月21日星期三

Flat file connection manager not parsing file correctly

Hi,

I have a flat file, comma-delimited, with strings in double-quotes.

In the connection manager for the file, I have specified that the Text Qualifier = ""

However, in the preview tab, it still shows the strings as surrounded by the quotes, e.g. "mycol1" whereas it should show mycol1 without the quotes.

Next, when I examine the data in the database after the load, it's messed up there also.

"mycol1" ends up in the database as "mycol1

"mycol2" ends up as "mycol2

This is not right.

I have format set to delimited, header row delimiter crlf, etc.

Any ideas?

Thanks

I sort of see what's happening.

The "mycol1 problem is due to the fact that I have mycol1 set as a string with a length of 6. Because it's not stripping off the double-quotes correctly, it counts the first six characters of "mycol1", which is of course "mycol1. It's counting the first double-quote as a character.

So the question remains, HOW do I get it to recognize the fact that "" are the text delimiters?

I remember setting up this same flat file connection before and it worked, but now it's not.

|||

Nevermind!

The text delimiter is ", not ""!!

doh

sql