解析CSV问题...... [英] Parsing CSV issues...

查看:100
本文介绍了解析CSV问题......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在编写一个例程,用于从CSV读取数据我打开文件,修剪掉不需要的标题并获取数据,我可以输入一个并使用foreach()解析它以单独获取数据,但是似乎有一个可能导致数据从记录到记录的错误位置。如果我在Excel中查看CSV,则没有明显的区别。当Excel(控制字符)以CSV格式保存时,是否可以插入一些字符?

Hi All,
I am writing a routine for reading in data from a CSV I have it opening the file, trimming off the unwanted headers and getting to the data, I can get an entry out and parse it with a foreach() to get the data individually however there seems to be an off set of one which can result in the data being in the wrong place from record to record. If I view the CSV in Excel there is not a visible difference. Can there be some characters inserted by Excel (control characters) that are left when it saves it out as a CSV ?

推荐答案

格伦,你为什么要重新发明轮子?

C#CSV阅读器和作家 [ ^ ]

快速CSV阅读器 [ ^ ]

将为你完成这项工作,并且比酿造自己的麻烦要少得多。
Glenn, why are you reinventing the wheel?
C# CSV Reader and Writer[^]
A Fast CSV Reader[^]
Will do the job for you, and a lot less hassle than "brewing your own".


这篇关于解析CSV问题......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆