解决CSV字段数据带有双引号的问题

2009-05-12 22:32:30来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

主要解决CSV字段数据带有双引号的问题

具体代码如下:

以下为引用的内容:

        Public Function ChangeCsvSplitLine(ByVal strLine As String, ByVal iColNumber As Integer) As String()
        Dim strList() As String = strLine.Split(",")
        If strList.Length = iColNumber Then
        Return strList
        End If

        Dim i As Integer = 0
        Dim findSplitIndex As Integer = -1
        Dim index As Integer = 0
        Dim returnList(iColNumber) As String
        Dim strMerger As String = ""
        For i = 0 To strList.Length - 1
        If findSplitIndex = -1 Then
        If (strList(i)(0) = """" And strList(i)(strList(i).Length - 1) <> """") _
        Or (strList(i).Length = 1 And strList(i) = """") Then
        findSplitIndex = i
        Else
        returnList(index) = strList(i)
        index = index + 1
        End If
        Else
        If (strList(i)(0) <> """" And strList(i)(strList(i).Length - 1) = """") _
        Or (strList(i).Length = 1 And strList(i) = """") Then
        strMerger = ""
        For findSplitIndex = findSplitIndex To i
        strMerger = strMerger & strList(findSplitIndex) & ","
        Next
        strMerger = strMerger.Substring(0, strMerger.Length - 1)
        returnList(index) = strMerger
        index = index + 1
        findSplitIndex = -1
        End If
        End If
        Next
        Return returnList
        End Function

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:.NET FileStreams将DTD插入XML文件中

下一篇:VB.net实现sql数据库的备份与恢复