我知道這個話題已經完成,但我已經完成了。使用C#使用OleDb解析CSV
我需要解析csv。這是一個相當平均CSV和分析邏輯已經使用OLEDB其他開發誰發誓,這他在休假:)去工作之前寫
CSV sample:
Dispatch Date,Master Tape,Master Time Code,Material ID,Channel,Title,Version,Duration,Language,Producer,Edit Date,Packaging,1 st TX,Last TX,Usage,S&P Rating,Comments,Replace,Event TX Date,Alternate Title
,a,b,c,d,e,f,g,h,,i,,j,k,,l,m,,n,
我的問題是,我得到不同的連接上各種錯誤字符串我嘗試。
當我嘗試連接字符串:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source="D:\TEST.csv\";Extended Properties="text;HDR=No;FMT=Delimited"
我得到的錯誤:
'D:\TEST.csv' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.
當我嘗試連接字符串:
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\TEST.csv;Extended Properties=Excel 12.0;
或連接字符串
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\TEST.csv;Extended Properties=Excel 8.0;
我得到的錯誤:
External table is not in the expected format.
我正在考慮扔掉所有的代碼,並從頭開始。有什麼明顯的我做錯了嗎?
我不能非常感謝你!你能指點我一些體面的csv解析器嗎?另外我可以在哪裏閱讀連接字符串?就像現在對我來說,它就像巫毒一樣。 –
@Zulfi Tapia,在我的回答結尾處,我指出了2 *精美的* CSV解析器。 –
非常感謝您的幫助! –