09-16-2014 04:45 AM
Hello,
i have a text-file with lots of lines. The file is imported to LV and need to be sorted by first character.
It works fine but gets very slow if too much lines.
If 40.000 lines then it takes 0.2s.
If 400.000 lines then the time rises with factor 100 to 25s.
if 1.000.000 lines then the time is 222sec (~4min)
Attached the code that sorts a text-array.
The number of lines can be set with the loop-counter (Loop-counter *4 = NumberOfLines)
The elapsed time is displayed.
How can i speed this up? (Or make the elapsed time more linear to the number of lines)
Thanks
Solved! Go to Solution.
09-16-2014 05:20 AM - edited 09-16-2014 05:25 AM
You can try something like this. If you process an array line by line you always end up taking long time.
Sorry I have some problem attaching the VI.
09-16-2014 05:36 AM
Looks good, but what is this icon in the small for-loop?
Thx
09-16-2014 05:41 AM
Its the same "String subset" primitive.
09-16-2014 06:41 AM
Speed is great now.
Only one problem with the "Sorting".
The lines contain a timestemp and now i have the wrong order after sorting.
How can i change it that the order is the same as in input-array and it only sorts by "first character"?
Thx
09-16-2014 07:39 AM
Can you show the code that you modified and also attach the text file if possible to see the type of data.
09-16-2014 07:45 AM
It is exactly your code that i am executing only different input data.
For example:
C|5|20140911-165529|7|S1|5,000|0,001|1
C|5|20140911-165629|7|S1|5,000|0,001|1
C|1|20140911-165729|7|S1|5,000|0,001|1
C|1|20140911-165829|7|S1|5,000|0,001|1
C|5|20140911-165929|7|S1|5,000|0,001|1
Here the timestamp is going higher each line, but because the third-character changes from "5" to "1" the Sorting will put these lines to the beginning.
And this changes the order of the tiimestamp after sorting.
09-16-2014 08:06 AM
Try sorting this way. This worul take little more time than the previous one for sorting.
09-16-2014 08:08 AM - edited 09-16-2014 08:19 AM
Like this?
09-16-2014 08:11 AM
Nice solution.
For this you must know the 1st character, in my solution its not required. I like the solution though