Jump to content

Sorting 2D Array Data?


Recommended Posts

Hey all,

I am stuck, I am trying to ficure out how to sort data in a 2D array. I would like to have is sorted in decending or ascending order. but I would like to be able to choose multiple columns to do this. Currently I use Excel to do what I need as I have made some Vis based off of the Report Generation Tool kit.

if there is any way that I could do this without having to have Excel that is what I am looking for.

Any suggestions on where to start?

Thanks

Link to comment
Hey all,

I am stuck, I am trying to ficure out how to sort data in a 2D array. I would like to have is sorted in decending or ascending order. but I would like to be able to choose multiple columns to do this. Currently I use Excel to do what I need as I have made some Vis based off of the Report Generation Tool kit.

if there is any way that I could do this without having to have Excel that is what I am looking for.

Any suggestions on where to start?

Thanks

Samples of the data and vi's are aways good for getting a quality answer and making sure the answering person doesn't spin their wheels trying to fill in the blanks. The LAVA forums make that easy.

Since I don't want to spin, I will make a general answer: index out the column and sort it, put it back together.

Mike

Link to comment
Start here - it already exists in the OpenG toolkit.

I assume I need OpenG Commander to get that toolkit? If so, I am not able to access it from work. I have OpenG Cpmmander installed, but it times out. I assume it is a firewall issue but I cannot find any setting to chnge it.

Samples of the data and vi's are aways good for getting a quality answer and making sure the answering person doesn't spin their wheels trying to fill in the blanks. The LAVA forums make that easy.

Since I don't want to spin, I will make a general answer: index out the column and sort it, put it back together.

Mike

See attach sample of data.. it is in a CSV text file. I will remove 2 header lines leaving one.

this is for my project at home. this is Automotive scan data.. Lets say I will want to sort by Engine Speed, then by MAP then by BLM, Then maybe 2 or 3 others. I have no code started for what I want to do with it other then the sorting features of excel.

Download File:post-5194-1153410247.txt

Link to comment
I assume I need OpenG Commander to get that toolkit? If so, I am not able to access it from work. I have OpenG Cpmmander installed, but it times out. I assume it is a firewall issue but I cannot find any setting to chnge it.

See attach sample of data.. it is in a CSV text file. I will remove 2 header lines leaving one.

this is for my project at home. this is Automotive scan data.. Lets say I will want to sort by Engine Speed, then by MAP then by BLM, Then maybe 2 or 3 others. I have no code started for what I want to do with it other then the sorting features of excel.

So you want to duplicate an 'auto filter data sort' where all the columns are sorted according to the sort of a particular column...you don't just want to pull out one column and sort it alone and reasssemble?

Link to comment

You need to get an list of column indices that you want to sort by.

first by column 2, then 1, then 3, then 5

Then reverse this list (5,3,1,2)

Then sort in that order as already described. (Sort by column 5, then sort again by column 3, ...)

Link to comment
I assume I need OpenG Commander to get that toolkit? If so, I am not able to access it from work. I have OpenG Cpmmander installed, but it times out. I assume it is a firewall issue but I cannot find any setting to chnge it.

See attach sample of data.. it is in a CSV text file. I will remove 2 header lines leaving one.

this is for my project at home. this is Automotive scan data.. Lets say I will want to sort by Engine Speed, then by MAP then by BLM, Then maybe 2 or 3 others. I have no code started for what I want to do with it other then the sorting features of excel.

You can still get all the packages from OpenG without using commander, Jim might chime in here if he can provide a link to help you get them. Then you can use commander to install them from a local disk.

Link to comment
So you want to duplicate an 'auto filter data sort' where all the columns are sorted according to the sort of a particular column...you don't just want to pull out one column and sort it alone and reasssemble?

Correct, All the rows are corellated. My other thought is to expand on somethign I already have done and instead of sorting, creat a progrma to search for the data needed..

As for OpenG commander, I found info on that website to posibly get it working, if not I will install it at home which is where i want/ need it anyway

Link to comment
Correct, All the rows are corellated. My other thought is to expand on somethign I already have done and instead of sorting, creat a progrma to search for the data needed..

As for OpenG commander, I found info on that website to posibly get it working, if not I will install it at home which is where i want/ need it anyway

What you want is a database function that has been shoe-horned into Excel. It might be easier to use a database. I definitely don't have the LV method in my head.

To all: Does Open G do that? Rearrange the rows based on a sort of a single coulmn?

To JD: I coiuld help you with what I thought was a newbie question about how to work with a 2D array. I am interested to do the record sort, but I know I don't have time right now. Sorry about that.

See what I mean about code samples and a good description to start off a discussion? I am glad I didn't make a totally unsuitable example to show you something you don't want to know about.

Link to comment

You could convert the 2D array into a 1D array of clusters.

The cluster would consist of as many scalars as you have columns in your 2D array. Build the clusters such that the primary sort column is the first element of the cluster, the secondary sort column is second, etc.

Sort the 1D array of clusters using Labview's 1D Array Sort.

Convert the Cluster back into a 2D array, putting the columns back in the correct order.

This may or may not be practical to implement, depending on the number of columns you have.

Link to comment
What you want is a database function that has been shoe-horned into Excel. It might be easier to use a database. I definitely don't have the LV method in my head.

To all: Does Open G do that? Rearrange the rows based on a sort of a single coulmn?

To JD: I coiuld help you with what I thought was a newbie question about how to work with a 2D array. I am interested to do the record sort, but I know I don't have time right now. Sorry about that.

See what I mean about code samples and a good description to start off a discussion? I am glad I didn't make a totally unsuitable example to show you something you don't want to know about.

Yep, I understand about examples, if I had something I would have attached it. I did get OpenG to work, but due to the firewall I manually download the toolkits. I downloaded the array OpenG toolkit kit and yes there is a Vi to sort a 2D array based off of one Column or Row. Seeing that has given me some Ideas now.

You could convert the 2D array into a 1D array of clusters.

The cluster would consist of as many scalars as you have columns in your 2D array. Build the clusters such that the primary sort column is the first element of the cluster, the secondary sort column is second, etc.

Sort the 1D array of clusters using Labview's 1D Array Sort.

Convert the Cluster back into a 2D array, putting the columns back in the correct order.

This may or may not be practical to implement, depending on the number of columns you have.

You know, that might work out well, I would not really need to convert back to the 2D array but once I get something going I will decide. I used Excel intially since it was simple to add and control. but the more I thought of it is If I built a stand alone app without excel, I am stuck. I will try it and see what happens.

As for size, the current data is 56 columns and 12031 rows. The rows can be less or more depending on the data. The Data is streamed to a file from a car (OBDI) I am in process of making my own OBDI scan tool (for my GM) I have somethign that currently manipulates data from a 'Off the shelf' scanner but my goal is to make an all-in-one program.

My movtivation started after taking the NI Intermediate courses. using the Producer-consumer Template. It is also a great way to practice as well.

Link to comment
Yep, I understand about examples, if I had something I would have attached it. I did get OpenG to work, but due to the firewall I manually download the toolkits. I downloaded the array OpenG toolkit kit and yes there is a Vi to sort a 2D array based off of one Column or Row. Seeing that has given me some Ideas now.

You know, that might work out well, I would not really need to convert back to the 2D array but once I get something going I will decide. I used Excel intially since it was simple to add and control. but the more I thought of it is If I built a stand alone app without excel, I am stuck. I will try it and see what happens.

As for size, the current data is 56 columns and 12031 rows. The rows can be less or more depending on the data. The Data is streamed to a file from a car (OBDI) I am in process of making my own OBDI scan tool (for my GM) I have somethign that currently manipulates data from a 'Off the shelf' scanner but my goal is to make an all-in-one program.

My movtivation started after taking the NI Intermediate courses. using the Producer-consumer Template. It is also a great way to practice as well.

What can you do with this data if it is out of chronological order?

Once you get it out of Excel the filesize will no longer bog down the production and viewing of graphs...

I don't get it.

Link to comment
What can you do with this data if it is out of chronological order?

Once you get it out of Excel the filesize will no longer bog down the production and viewing of graphs...

I don't get it.

Let me try to explain what I am doing and where I stand now

In 2000, I started messing around with the fuel curves in my car (89 GM OBD1) I have a program to datalog, I learned what the target is for the fuel curve, and how to calculate changes, but I did not want to spend hours going through the data manually., so I wrote a basic program in LabVIEW to do it for me. Originally I would manually sort the data in Excel, save it as a CSV Text file, then push the Sorted Text file through my program. At the time the program was made there were 3 Variables RPM, BLM, and MAP. The BLM was the Actual fueling # and the RPM and MAP were sort of pointers to the BLM. These 3 are in a table MAP was in ascending Columns and RPM ascending rows. I sorted based on RPM, Then MAP. I used 2 For Loops, one inside the other, the Outer did the rows, the inner did the MAP. Then the BLM was calculated against the original value and replaced. The For loops would read form the 2D array with the current fueling BLM then look in my scanned Data (like the attached above) and change the variables.

I noticed the program was not correct, I forgot to Average the BLM if I have multiple RPM and MAP Values (eg. if I had 6 RPM values of 2200 and 6 with a MAP of 50 but 6 different BLM #s) This is where the sorting was needed. I wanted something that would run well, to sort and Average my data into something useful. First attempts made the program REALLY Slow, but after sorting the data, it has improved (along with 6 years of technology with the PC) So I left the program the way it was with the sorting.

Now a couple weeks ago I got a bug to redo it, improve and make it more efficient (first version of my program was written in LV5) I was still learning (as I still am) but I over used Locals and a few other things. At the time is worked, looking back at it now, I know it will be done better.

Other things that were manually removed from the scanned file were OPEN LOOP, LEARN CONTROL OFF, those I can use the simple 2d Sort of One column and delete the unwanted after I sort. I need to double check my code to see how I am looking for duplicates, maybe I don

Link to comment
You guessed it. I don't follow you at all. I think you are processing sensor data from your ECM to make a control map for your vette. But I don't get it.

You got it.. once I figure out what I am doing for the sorting I will post the code

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.