我正在尝试解析文本文件的灾难。它应该在每一行(CSV)中有24列,但它没有。我必须对文件进行一些处理,我正在使用VB.Net的脚本组件来执行此操作。脚本组件中的代码可以很好地解析好的行,但是我想让它将坏行输出到不同的平面文件,但没有运气。
以下是我正在使用的代码:
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
If Not Row.Column0_IsNull AndAlso
Not String.IsNullOrEmpty(Row.Column0.Trim) Then
Dim strDQ As String = Chr(34) + Chr(34) + Chr(34)
Dim strRow As String = Row.Column0.Replace(strDQ, Chr(34))
Dim strColumns As String() = strRow.Split(CChar(","))
If strColumns.Length <> 24 Then Exit Sub
Output0Buffer.AddRow()
Output0Buffer.Column = strColumns(0)
Output0Buffer.Column1 = strColumns(1)
Output0Buffer.Column2 = strColumns(2)
Output0Buffer.Column3 = strColumns(3)
Output0Buffer.Column4 = strColumns(4)
Output0Buffer.Column5 = strColumns(5)
Output0Buffer.Column6 = strColumns(6)
Output0Buffer.Column7 = strColumns(7)
Output0Buffer.Column8 = strColumns(8)
Output0Buffer.Column9 = strColumns(9)
Output0Buffer.Column10 = strColumns(10)
Output0Buffer.Column11 = strColumns(11)
Output0Buffer.Column12 = strColumns(12)
Output0Buffer.Column13 = strColumns(13)
Output0Buffer.Column14 = strColumns(14)
Output0Buffer.Column15 = strColumns(15)
Output0Buffer.Column16 = strColumns(16)
Output0Buffer.Column17 = strColumns(17)
Output0Buffer.Column18 = strColumns(18)
Output0Buffer.Column19 = strColumns(19)
Output0Buffer.Column20 = strColumns(20)
Output0Buffer.Column21 = strColumns(21)
Output0Buffer.Column22 = strColumns(22)
Output0Buffer.Column23 = strColumns(23)
Else
Row.DirectRowToOutput1()
End If
End Sub
我花了一个小时左右在脚本组件中使用ExclusionGroup和Synchronious Output设置,但是没有成功。你们所能提供的任何帮助都会很棒。谢谢。
答案 0 :(得分:0)
错误出现在其中一个If语句中 - 我需要处理行而不是退出sub。现在工作。遗憾!