M


Replace only the entire Main function from below code

-----------------------------------------

Public Sub Main()

    Dim inputFile As String = Dts.Variables("inputFileName").Value.ToString()


    Dim lines As New List(Of String)()


    Using reader As New System.IO.StreamReader(inputFile)

        While Not reader.EndOfStream

            Dim line As String = reader.ReadLine()


            Dim fields As String() = line.Split(","c)

            MsgBox(line + " index " + fields.Length.ToString())

            ' Check if the number of fields is greater than 14

            If fields.Length <> 14 Then

                ' Find the second comma index

                Dim secondCommaIndex As Integer = line.IndexOf(","c, line.IndexOf(","c) + 1)


                ' Remove the second comma

                line = line.Remove(secondCommaIndex, 1)

                MsgBox(line + " index " + secondCommaIndex.ToString())

            End If


            ' Add the modified line to the list

            lines.Add(line)

        End While

    End Using


    ' Write the modified content back to the input file

    System.IO.File.WriteAllLines(inputFile, lines.ToArray())


    Dts.TaskResult = ScriptResults.Success

End Sub