Results 1 to 10 of 10

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

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2013
    Posts
    295

    Question 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
    Last edited by NJDevils28; May 20th, 2013 at 10:35 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width