开发者

WP7 - read from CSV file? Or what to do with the data?

I have a CSV file of data which I'm attempting to use in my Windows Phone 7 application. I'm trying to figure out how to open and consume the data in my app. I've seen some examples around about using Linq to do this, but they use OleDB to open the CSV file.

Note: I want to deploy the data with my app, instead of using a Web Service, because it is cleaner and not that much data. If there is no coding way to do it, perhaps a w开发者_如何学运维ay to convert to XML?


Nothing wrong with using light weight CSV input files.

You can use StreamReader.Readline to pull in a line at a time.

And String.Split to parse the comma seperated values into usable elements. For example:

string csv = "abc,123,def,456";
string[] elements = csv.Split(',');
foreach (string s in elements)
    System.Diagnostics.Debug.WriteLine(s);


Still no third-party library for CSV-parsing in Windows Phone apps at the time of this answer...

If you need to parse CSV with quotes, see this answer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜