方法:
1、打开EXCEL单元格,数据单元格B1列输入="'"&A1。
2、之后向下填充即可。
3、一般加单引号是为了转换为文本,可直接选择数据列,选择工具栏的文本样式即可。
主要解决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 = Dim findSplitIndex As Integer = Dim index As Integer = Dim returnList(iColNumber) As String Dim strMerger As String = For i = To strList Length If findSplitIndex = Then If (strList(i)( ) = And strList(i)(strList(i) Length ) <>) _ Or (strList(i) Length = And strList(i) = ) Then findSplitIndex = i Else returnList(index) = strList(i) index = index + End If Else If (strList(i)( ) <>And strList(i)(strList(i) Length ) = ) _ Or (strList(i) Length = And strList(i) = ) Then strMerger = For findSplitIndex = findSplitIndex To i strMerger = strMerger &strList(findSplitIndex) & Next strMerger = strMerger Substring( strMerger Length ) returnList(index) = strMerger index = index + findSplitIndex = End If End If Next Return returnList End Function
lishixinzhi/Article/program/net/201311/15450
创建一张临时表。
然后
bulk insert 表名 from '文件地址' with
(
fieldterminator=',',
rowterminator='\n'
)
select * from 表名 这里查出来应该带引号
然后你删除这表的数据
delete from 表名
然后
把fieldterminator=',', 改为:fieldterminator='","',
重新执行insert语句 然后再查询 试试吧。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)