更新CSV解析脚本

时间:2015-12-15 18:49:53

标签: sql vba csv

我正在尝试修改解析脚本以排除第一个字段中没有值但我希望脚本完成该文件的记录。

lastRO = ""
FirstLine = True
FacilityCode = Left(InputFile, InStr(InputFile,"_")-1)

Do Until EOF
    a = CSVParser(ExtractLine(0))

If a(1) <> lastRO Then
    If FirstLine Then
        FirstLine = False
    Else
        WriteFields()

    End If
    lastRO = a(1)
    Field("Department") = ""
    Field("RepairOrder") = FacilityCode & a(1)
End If
Dim xReg
Set xReg = new  RegExp
For i = 0 to Ubound(RepairOrderDepartmentExpressions)
    xReg.Pattern = RepairOrderDepartmentExpressions(i)
    If xReg.Test(a(RepairOrderDepartmentField(i))) Then
        If Field("Department") = "" Or Field("Department") = RepairOrderDepartmentKey(i) Then
            Field("Department") = RepairOrderDepartmentKey(i)
        Else
            Field("Department") = RepairOrderSharedDepartment
        End if
        Exit For
    End if
Next
Skip
Loop

0 个答案:

没有答案