当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > 解决CSV字段数据带有双引号的问题

ASP.NET
给Asp.Net初学者的关于继承和多态性的例子
新手入门:C++下的引用类型
初学者的福音:游戏开发新手入门指南
C/C++中利用空指针简化代码,提高效率
获取转向地址的URL的源文件(可自定义REFER)
asp.net中执行存储数据操作时数据被自动截取的一种情况
.NET中防止Access数据库下载
vs.Net2003无法打开或创建Web应用程序若干解决办法.
我今天开始正式学习.net遇到的问题
无法在Web服务器上启动调试。未将项目配置为进行调试
找不到类型或命名空间名称“Server”(是否缺少 using 指令或程序集引用?)
ASP.NET页面间的传值的几种方法
几个ASP.NET技巧
让Asp.NET的DataGrid可排序、可选择、可分页
web.config文件的中文解释
用DataReader还是DataSet?
ASP.NET中数据库操作初步
ExecuteReader(),ExecuteNonQuery(),ExecuteScalar(),ExecuteXmlReader()之间的区别
如何在DataGrid控件中实现自定义分页
ADO.NET 的最佳实践技巧

ASP.NET 中的 解决CSV字段数据带有双引号的问题


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 128 ::
收藏到网摘: n/a

主要解决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