Check Validation for Headers and Column Counts in .CSV File using SSIS

随声附和 提交于 2020-05-18 16:58:49

问题


Qn,

I have CSV file with 8 columns. Importing it in SQL table via SSIS . The file needs to fail if the columns of the csv file are more or less.

Qn,

Also is there a check for valid headers in the csv file. the testers have tested it with the data as header and out of 13 rows it reads 5 rows . I need to throw error if there is incorrect header as well.

Please advise...Thanks


回答1:


for your firSt question you can use following script in vb.net to check the number of columns in file with extension ".csv"

If reader.EndOfStream Then
MessageBox.Show("The CSV file is empty, please update", _
            "Error", MessageBoxButtons.OK)
Application.Exit()
End If

'Dim s As String = reader.ReadLine()
Dim lineContents() As String = Split(reader.ReadLine(), ",")
Dim NoOfCol As Integer

NoOfCol = lineContents.Length

IF not NoOfCol = 8
MessageBox.Show("Error")
End IF


来源:https://stackoverflow.com/questions/21006948/check-validation-for-headers-and-column-counts-in-csv-file-using-ssis

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!