编码以下内容的最佳方式 [英] Best way to code the following

查看:171
本文介绍了编码以下内容的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在内存中读取大约100行csv文件。


每行包含6个字段。


什么是最好的方法将其存储到内存中然后再读回来。


这是一个多dimsion数组的数组。


如果是这样的话,我可以使用每行的arraylist将数据读入数组

和字符串数组中的字段但是看不出我如何获取数据

退出。


期待评论

I need to read about 100 lines of a csv file into memory.

Each line contains 6 fields.

What is the best way to store this into memory and then read it back.

Is a array of a multi- dimsion array the way to do this.

If so I can read the data into an array using an arraylist for each line
and the fields in a string array but cannot see how I can get the data
back out.

Looking forward to comments

推荐答案

您的问题是有问题的,因为它是开放式的主观。什么

做最佳方式对你来说意味着什么?


就个人而言,我会将数据存储在数据表或列表中< twhere t

=强类型类。


Web上有大量样本用于读取和解析CSV文件。

这些包括OLEDB解决方案,正则表达式解决方案和简单的程序
解析。

" Jeff" < jeff @ [_ nospam _] .hardsoft.com.auwrote in message

news:13 ************ @ corp.supernews.com ...
Your question is problematic because it is open ended and subjective. What
does "Best Way" mean to you?

Personally, I would store the data in either a datatable or list<twhere t
= strongly typed class.

There are a bunch of samples on the web for reading and parsing CSV files.
These include an OLEDB solution, a regex solution, and plain ''ol procedural
parsing.
"Jeff" <jeff@[_nospam_].hardsoft.com.auwrote in message
news:13************@corp.supernews.com...

>我需要在内存中读取大约100行csv文件。


每行包含6个字段。


将它存储到内存然后再读回来的最佳方法是什么。


是一个多dimsion数组的数组的方法这个。


如果是这样的话,我可以使用每行的arraylist将数据读入数组

和字符串数组中的字段但是看不出我是怎么回事可以获得数据

退出。


期待评论
>I need to read about 100 lines of a csv file into memory.

Each line contains 6 fields.

What is the best way to store this into memory and then read it back.

Is a array of a multi- dimsion array the way to do this.

If so I can read the data into an array using an arraylist for each line
and the fields in a string array but cannot see how I can get the data
back out.

Looking forward to comments




正确读取CSV文件可能比简单地分割字符串要复杂得多。这是一个优秀的CSV阅读器。


快速CSV阅读器
http://www.codeproject.com/cs/database/CsvReader.asp


HTH,


Sam


--------------------------- ---------------------------------

我们正在招聘! B-Line Medical正在寻求.NET

开发人员在医疗产品中的激动人心的职位

开发MD / DC。在轻松的团队环境中使用各种技术

。在Dice.com上查看广告。


2007年9月25日星期二23:40:17 +1000,Jeff

< jeff @ [_ nospam_]。 hardsoft.com.auwrote:

Properly reading a CSV file can be a lot more complicated than simply
splitting strings. Here''s an excellent CSV reader.

A Fast CSV Reader
http://www.codeproject.com/cs/database/CsvReader.asp

HTH,

Sam

------------------------------------------------------------
We''re hiring! B-Line Medical is seeking .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.

On Tue, 25 Sep 2007 23:40:17 +1000, Jeff
<jeff@[_nospam_].hardsoft.com.auwrote:

>我需要在内存中读取大约100行csv文件。

每行包含6行字段。

将它存储到内存然后再读回来的最佳方法是什么。

是一个多dimsion数组的数组就是这样做的。

如果是这样的话,我可以使用每行的arraylist和字符串数组中的字段将数据读入数组,但无法看到我如何将数据恢复出来。

期待评论
>I need to read about 100 lines of a csv file into memory.

Each line contains 6 fields.

What is the best way to store this into memory and then read it back.

Is a array of a multi- dimsion array the way to do this.

If so I can read the data into an array using an arraylist for each line
and the fields in a string array but cannot see how I can get the data
back out.

Looking forward to comments


它不是读取或写入CSV文件的问题我是

无法找到如何将数据放入多重演示数据的示例,以及如何将数据从arral中取出。


据我所知,我必须使用ArrayList,以便它可以增长动态ly。


问候

杰夫


杰夫写道:
Its not the reading or writing the CSV file which is the issue it is I
cannot find an example of how to place data into a multi-demsendion
array and then how to get the data back out of the arral.

As far as I can see I must use an ArrayList so it can grow dynamically.

Regards
Jeff

Jeff wrote:

我需要在内存中读取大约100行csv文件。


每行包含6个字段。


什么是将其存储到内存中然后再读回来的最佳方式。


这是一个多dimsion数组的数组。


如果是这样的话,我可以使用每行的arraylist将数据读入数组

和字符串数组中的字段但是看不出我如何获取数据

退出。


期待评论
I need to read about 100 lines of a csv file into memory.

Each line contains 6 fields.

What is the best way to store this into memory and then read it back.

Is a array of a multi- dimsion array the way to do this.

If so I can read the data into an array using an arraylist for each line
and the fields in a string array but cannot see how I can get the data
back out.

Looking forward to comments


这篇关于编码以下内容的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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