Dans SSIS, j'essaie de charger des données à partir d'un file plat. Le file plat a des colonnes de largeur fixe, mais certaines colonnes ne sont pas présentes dans une rangée (une colonne peut avoir un CRLF, qui doit être une nouvelle ligne) comme ceci
abc the first rowok<CRLF> iu jjrjdd<CRLF> this is a newline<CRLF>
Comment puis-je avoir exactement le même nombre de lignes et de données exactes dans ma sortie?
Je configure une connection de file à plat, de type droit irrégulier.
Dans cet exemple, la ligne 1 est correctement récupérée, mais pour la ligne 2, elle n'a pas reconnu CRLF, et a mis en colonne b toutes les lignes 3 …
Merci d'avance
Cordialement,
Xavier
DT_STR
Colonnes délimitées par des tabulations
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer) If Not Row.Column0_IsNull AndAlso Not Ssortingng.IsNullOrEmpty(Row.Column0.Trim) Then Dim str() As Ssortingng = Row.Column0.Split(CChar(vbTab)) If str.Length >= 3 Then Row.a = str(0) Row.b = str(1) Row.c = str(2) ElseIf str.Length = 2 Then Row.a = str(0) Row.b = str(1) Row.c_IsNull = True ElseIf str.Length = 1 Then Row.a = str(0) Row.b_IsNull = True Row.c_IsNull = True Else Row.a_IsNull = True Row.b_IsNull = True Row.c_IsNull = True End If Else Row.a_IsNull = True Row.b_IsNull = True Row.c_IsNull = True End If End Sub
Colonnes à largeur fixe
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer) If Not Row.Column0_IsNull AndAlso Not Ssortingng.IsNullOrEmpty(Row.Column0.Trim) Then 'Assuming that 'Col a => 0-5 'Col b => 5-15 'Col c => 15- Dim intlength As Integer = Row.Column0.Length If intlength <= 5 Then Row.a = Row.Column0 Row.b_IsNull = True Row.c_IsNull = True ElseIf intlength > 5 AndAlso intlength <= 15 Then Row.a = Row.Column0.Subssortingng(0, 5) Row.b = Row.Column0.Subssortingng(5, 10) Row.c_IsNull = True ElseIf intlength > 15 Then Row.a = Row.Column0.Subssortingng(0, 5) Row.b = Row.Column0.Subssortingng(5, 10) Row.c = Row.Column0.Subssortingng(15) End If Else Row.a_IsNull = True Row.b_IsNull = True Row.c_IsNull = True End If End Sub
Vous pouvez également y parvenir en utilisant la transformation de colonne dérivée