Validating File

Results 1 to 2 of 2

Thread: Validating File

  1. #1
    Join Date
    Dec 1969

    Default Validating File

    The problem I&#039;m having is I&#039;m trying to validate a comma delimited file. If they enter an extra , in a field this captures it, but if they leave it blank and the file get placed in as dog, cat,, rabbit then of course it fails. How do you capture for this. My code is below. Any help would be appreciated. Thanks,<BR><BR>If sFileExtention = "csv" Then<BR> Dim objFileTextSteam<BR> Set objFileTextStream = objFile.OpenAsTextStream(1, -2)<BR> sLine = ""<BR> Do while objFileTextStream.AtEndOfStream &#060;&#062; True<BR> RowMessage = ""<BR> sLine = objFileTextStream.ReadLine <BR> aRecord = ""<BR> sColumn = "Passed"<BR> aRecord = Split(sLine,",")<BR> sFailed = ""<BR> sUpdate = ""<BR> IF UBound(aRecord) = 141 Then <BR> %&#062;&#060;!--#INCLUDE FILE="_ScriptLibrary/_ArrayCheck.asp"--&#062;&#060;%<BR> Else<BR> sRowMessage = "Record " & x & " Failed because:" & vbCrlf & "There are " & Ubound(aRecord)+1 & " columns in the record and the system is expecting 142 columns. The most common cause of this is a placement of a comma within the data you are attempting to import."<BR> iEntryID = iEntryID + 1<BR> sPassed = InsertImportErrorLog(intImportNum,iEntryID,"Row Failed",sRowMessage)<BR> End If<BR> x = x + 1<BR> Loop<BR> End IF<BR>

  2. #2
    Join Date
    Dec 1969

    Default I'm really surprised...

    ...that this isn&#039;t checked for in your "_ArrayCheck.asp" code.<BR><BR>What&#039;s the point of having that code separate if it doesn&#039;t *actually* do the check????<BR><BR>And what&#039;s the point of the line<BR> aRecord = ""<BR>??? Considering that just 2 lines after than you assign the *real* value to aRecord???<BR><BR>Anyway, I would assume that seeing <BR> dog,,cat,...<BR>isn&#039;t the ONLY kind of error you could get.<BR><BR>What if there&#039;s a space between the commas? Or lots of spaces? Or...<BR> dog, , cat , ...<BR><BR>Sure, we could write code to check for those errors and put it in here, but why? Why doesn&#039;t the _ArrayCheck.asp code do that?<BR><BR>

Posting Permissions

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