Reputation: 1
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
Upvotes: 0
Views: 1401
Reputation: 551
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
Upvotes: 1