打开由竖线字符"|"分隔的csv文件.是否通用分隔符 [英] Open csv file delimited by pipe character "|" or not common delimiter
本文介绍了打开由竖线字符"|"分隔的csv文件.是否通用分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试建立一个Excel VBA代码,该代码打开一些.csv文件,并将由字符|
包含和分隔的信息分成几列.我设法打开了文件,但是我使用的代码打开了我的文件,而没有根据定界符分割文本.到目前为止,我已经尝试了以下代码:
I'm trying to set up an Excel VBA code that opens up some .csv files and split into columns the information contained and delimited by the character |
. I manage to open the file but the code I use opens my files without splitting the text according to the delimiter. So far I have tried the following code:
Sub OpenCSV()
Dim wkbTemp As Workbook
Dim sPath As String, sName As String
sPath = ThisWorkbook.Path & "\CSV_Files\"
sName = "Test.csv"
Set wkbTemp = Workbooks.Open(Filename:=sPath & sName, Format:=6, Delimiter:="|")
End Sub
推荐答案
我记得这让我发疯了.
似乎Excel对.csv
文件具有不受控制的贪婪.如果仅更改结尾(.txt
,.dat
或其他内容),它将起作用!
I remember this has driven me insane some time back.
It seems that Excel has an uncontrolled greed for .csv
files. If you just change the ending (.txt
, .dat
or whatever), it will work!
这篇关于打开由竖线字符"|"分隔的csv文件.是否通用分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文