如何解决CSV字段数据的双引号问题_.Net教程
1个回答
展开全部
技术工具箱: VB.NET, XML, ADO.NET ADO.NET提供了一种很好的功能来处理dataset和XML之间的转换。你可以通过VS.NET在XML中形象地创如何解决CSV字段数据的双引号问题,主要解决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 IfDim 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 = iElsereturnList(index) = strList(i)
index = index 1End IfElseIf (strList(i)(0) <> """" And strList(i)(strList(i).Length - 1) = """") _
Or (strList(i).Length = 1 And strList(i) = """") Then
strMerger = ""
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询