.csv文件wint特定字段的大数据字符串排序 [英] Sorting big data string of .csv file wint specific field

查看:81
本文介绍了.csv文件wint特定字段的大数据字符串排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
目前我正在研究文件读写机制,
我有从SAP生成的.csv文件,几乎包含65000行的数据,整个文件充满了没有行的数据.
具有以下格式

项目代码 项目描述 项目频率 项目速率

现在是我的工作标准,
1)我想根据项目描述对.csv文件的数据进行排序
已应用以下逻辑进行排序

Hi All,
Currently i''m working on the file reading and writing mechanism,
I have .csv file genarated from SAP ,contain almost data of 65000 lines that is whole file is filled with data no rows remains.
has following format

item codeitem descriptionitem quentityitem rate

now my working criterias,
1)I want to sort data of .csv file according to item description
have applied following logic for sorting

for(int n=0;n<item_desc.getcount();n++)>
   {
   for(int y=n;y<item_desc.getcount();y++)>
      {
      if(Item_desc.ElementAt(n).compareNocase(Item_desc.ElementAt(y))
         {
         SWapArray(Item_desc,n,y);          //function that swap elements
         SWapArray(Item_Code,n,y);
         SWapArray(Item_Quantity,n,y);
         SWapArray(Item_Rate,n,y);
         }
      }
   }



逻辑上没有问题,但是对于这种单次排序,则需要1.5小时.

那么上述逻辑是否有替代方法
2)第二个标准取决于上述问题的解决方案.


[edit]改进了代码块的格式-OriginalGriff [/edit]
_____________________________________________________________________________
欢迎所有链接,代码块,建议.



No problem with logic but for this single sorting take 1.5 HOURS required.

So Is There is alternative for above logic
2)Second criteria depend on solution of above problem.


[edit]Formatting improved in code block - OriginalGriff[/edit]
_____________________________________________________________________________
All links,code block, suggestion are welcome

推荐答案

首先,这看起来像是一种原始的排序,因此将排序算法更改为更高级的排序可能会产生结果.

但是,如果没有这些,您可以做一些事情:首先,找到瓶颈.这个过程的每个部分要花多长时间?你得知道. SWapArray函数做什么,如何做?为什么不将getcount调用移出循环?为什么仍要以这种格式保存数据?

我会做什么:用Desc,代码,数量和费率设置一个类.设置指向类实例的数组或类似的指针.
然后,我将使用内置的排序方法对指针(而不是实际数据)进行排序.我认为速度会更快...
Firstly, that looks like a pretty primitive sort, so changing your sort algorithm to a more advanced one would probably yield results.

But there are a few things you could do without that: Firstly, find your bottle neck. How long is each part of this taking? You need to know. What does the SWapArray function do, and how? Why not move the getcount calls outside the loops? Why hold the data in this format anyway?

What I would do: Set up a class with a Desc, Code, Quantity, and Rate. Set up an array or similar of pointers to the class instances.
Then I would use the built in sorting methods to sort the pointers, rather than the actual data. I think the speed would be considerably faster...


这篇关于.csv文件wint特定字段的大数据字符串排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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