Quantcast
Viewing all articles
Browse latest Browse all 27091

Solved ** - How to read a Line in a CSV File twice - Please help

Hello All,

I am having a bit of difficulty processing a CSV File.

My goal is to read the file and parse the separate fields (per record) into an array. If any of the fields are invalid, I need to write an error log with the record exactly as I read it, quotes/commas and all.

I am able to read the record into the array and process it but my error checking routine is giving me trouble. What I need to do is re-read the current record and write it to a file.

I do not know how to accomplish this. Here is how I am reading the file. If you could, would you point me in the right direction?


'Read the first record as the header Then write it to the Error File Then close the file
Code:

        Dim HeaderRow As String = myReader.ReadLine
        Dim OutputFile As String = ART2CSDfrm.OutputFile
        Dim myStreamWriter As New StreamWriter(OutputFile)
        myStreamWriter.WriteLine(HeaderRow)
        myStreamWriter.Close()
        Dim ErrorRow As String
        ' Create my Array
        Dim currentRow As String()

        While Not myReader.EndOfData
            Try
                'ErrorRow = myReader.ReadLine
                currentRow = myReader.ReadFields()

                Requestnum = currentRow(0)
                type = currentRow(1)
                ProgramName = currentRow(2)
                region = currentRow(3)
                ClientName = currentRow(4)
                ClientPhase = currentRow(5)
                ProgramType = currentRow(6)
                Admin = currentRow(7)
                Status = currentRow(8)
                Requestor = currentRow(9)
                RequestorEmail = currentRow(10)
                RequestorPhone = currentRow(11)
                dateSubmitted = currentRow(12)
                Priority = currentRow(13)
                CaseDesc = currentRow(14)
                EstimateLevel = currentRow(15)
                EstimateHours = currentRow(16)
                EstimatedBy = currentRow(17)

          End Try
      End While


Viewing all articles
Browse latest Browse all 27091

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>