简体   繁体   English

如何处理大量数据?

[英]How to handle large amounts of data?

I have a project for school where I was given 103MB of data (Water Stream Quality Results in Ontario) which equates to 200 000+ lines of data. 我有一个学校项目,我获得了103MB的数据(安大略省的水流质量结果),相当于200 000多行数据。 I need to be able to take in the data and create a visual out of it (eg a map of Ontario with dots representing where X chemical was found in 20XX). 我需要能够接收数据并从中创建视觉效果(例如安大略省的地图,其中的点表示在20XX中发现X化学物质的位置)。

I have tried taking in everything more or less all at once which my computer obviously couldn't handle. 我已经尝试过或多或少地接受了我的计算机显然无法处理的所有内容。 I was wondering if there is a strategy or function that can help me with this. 我想知道是否有可以帮助我的策略或功能。

I would preferable like to have the information in a 2D ArrayList after the data has been taken in. 我希望在获取数据后将信息放在2D ArrayList中。


Example

Array Name: rawData 数组名称:rawData

[0], [1], [2] [0],[1],[2]

2002, 2003, 2004 2002年,2003年,2004年

station num, station num, station num 站号,站号,站号

chem. 化学。 found, chem. 发现,化学。 found, chem. 发现,化学。 found 发现

etc. 等等

If this is an inefficient way to have the data stored, what would be a better way? 如果这是存储数据的低效方式,那么更好的方法是什么?


Any help would be appreciated. 任何帮助,将不胜感激。

Side Note: the data has been given to me over 10+ files. 附注:数据已经提供给我超过10个文件。 Also, the file extension is a .csv so each row is separated by a comma (eg [year, chemical found, concentration percent>, etc.]) 此外,文件扩展名为.csv,因此每行用逗号分隔(例如[year,chemical found,concentration percent>等])

You can use ArrayLists. 您可以使用ArrayLists。 Create a class with the values you need to store in the objects. 使用您需要存储在对象中的值创建一个类。

For eg : 例如:

class Data{
  String Year;
  String found;
  ---one property for each of the value you need--
}

You can then populate the objects of this class and add them to the arrayList. 然后,您可以填充此类的对象并将它们添加到arrayList。

In addition to Ardash's answer, you will probably need to read in the data in chunks. 除了Ardash的答案,您可能需要以块的形式读取数据。 If you use a BufferedReader, you can read CSV files line by line. 如果使用BufferedReader,则可以逐行读取CSV文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM