如何解决CSV字段数据的双引号问题_.Net教程

编辑Tag赚U币
教程Tag:暂无Tag,欢迎添加,赚取U币!

推荐:解析.NET FileStreams如何将DTD插入XML文件中
.NET类则更加方便,它会带给你更多使用上的灵活性。 技术工具箱: 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 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

分享: 解析VB.NET中的常量与枚举功能
在程序运行的过程中始终固定不变的量称为常量。由于在程序设计和开发时经常会反复地运用一些常数,而且它们代表的含义有时候非常难记,所以每次都需要去核对,如果定义了常量将使之简单化

来源:模板无忧//所属分类:.Net教程/更新时间:2008-12-01
相关.Net教程