欢迎您访问我爱IT技术网,今天小编为你分享的编程技术是:【解决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
以上所分享的是关于解决CSV字段数据带有双引号的问题,下面是编辑为你推荐的有价值的用户互动:
相关问题:如何实现excel转存csv全部字段自动加引号
答:方法: 1、打开EXCEL单元格,数据单元格B1列输入="'"&A1。 2、之后向下填充即可。 3、一般加单引号是为了转换为文本,可直接选择数据列,选择工具栏的文本样式即可。 >>详细
相关问题:带有双引号的CSV数据不能被正确识别
答:可以先另存下csv,就会变成逗号 >>详细
相关问题:SQL导入csv数据后,表格的数据有双引号,请问有人...
答:select replace(字段,'''','') from 表 要这样? >>详细
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
