|
|
|
|
  |
|
Compare 2 data grids (column 1)
Last Post 26 Jun 2010 08:01 PM by Tijn. 11 Replies.
|
Sort:
|
James
 |
| 02 Jun 2010 04:30 PM |
|
I am trying to compare 2 data grids. Grid 1 and Grid 2. It only has 1 column each and about 50 rows of data (stock symbols). I want to take the first grid and the first symbol then see if grid 2 contains this symbol. If grid 2 DOES NOT contain this symbol then place it in Grid 3, if it DOES contain place it in grid 4, then loop each new Symbol i know it has to contain Loop Grid, Get Data row value, but cant quite get how to do comparisons. Thanks for any help and a mini script.
|
|
|
|
|
Tijn
 |
| 08 Jun 2010 11:31 AM |
|
Which edition of Djuggler are you using?
|
|
|
|
|
JAMES
 |
| 08 Jun 2010 01:46 PM |
|
THANKS. i am evaluating the builder version on djuggler.
|
|
|
|
|
Tijn
 |
| 08 Jun 2010 02:00 PM |
|
In the datagrid advanced section, there is an action to compare two datagrids on a column. The result is a new datagrid exactly as you describe. When you open the properties of the action, there is a link to an action example script. Hope this helps. Tijn |
|
|
|
|
james
 |
| 09 Jun 2010 10:59 PM |
|
very cool functionality and very FAST! thank you for the reply.. |
|
|
|
|
James
 |
| 11 Jun 2010 03:41 PM |
|
i am using the compare grids and find it helpful, I wanted to be able to count the differences/similarities between the grids. What is the best way to count these sims/differences and store it into a variable? |
|
|
|
|
Tijn
 |
| 14 Jun 2010 07:10 PM |
|
A quick method to get the number of rows in a data grid is using the loop data grid rows action. You don't need to put action in the loop, you simply ask the total number of rows in a variable. See the attached example script.
|
rowcount.djs
|
|
|
|
james
 |
| 16 Jun 2010 05:00 PM |
|
thanks for the explanation... Continuing with the data grid. Lets says I do send differences/similarities between 2 grids to a 3rd grid. How can I label these conditions within the 3rd grid in order to know so I dont need to keep track of multiple grids.... I was thinking of a conditional "IF" but cant seem to work out the logic. Basically I want 1 grid that writes a label in column 1 based on diff or sim between grids instead of having multiple grids to track. These would be 3 scenerios (by label I mean place TEXT in column 1 or 5 etc) If similarity between G1 and G2, send to G3 and label "Keep". If in G1 but not in G2, send to G3 and label "BUY" If in G2 but not in G1, send to G3 and label "SELL" Hope this makes sense...
|
|
|
|
|
Tijn
 |
| 22 Jun 2010 12:07 PM |
|
I think your setup should be like this: Loop G1 on the rows. Then do a lookup in G2 on an identifier like the name of the stock with the Find in Data Grid action. If nothing is found the result row will be 0. Then you use the Set Data Cell value action to write an extra column in G3 with BUY and all the values. If a result row is returned greather then 0, you use the Get Data Cell value to compare the values and if the are the same, you set in G3 the remark KEEP. Next you loop the rows on G2 to see what is missing in G1 and put that in G3 same as before with the loop rows on G1. Hope this helps. |
|
|
|
|
Tijn
 |
| 22 Jun 2010 12:08 PM |
|
Perhaps you can post an attachment with csv files for G1 and G2, that would make things more clear to understand. |
|
|
|
|
james
 |
| 25 Jun 2010 06:33 PM |
|
thanks Tijn, I uploaded a .zip with 2 grids... if you can create a quick sample script I would appreciate it. I love the compare grid action but seems i cannot accomplish my goals with it. again this is the basis of what i am trying to achieve. If similarity between Grid1 and Grid2, send to Grid3 and label "Keep". If in G1 but not in G2, send to G3 and label "BUY" If in G2 but not in G1, send to G3 and label "SELL" |
Desktop.zip
|
|
|
|
Tijn
 |
| 26 Jun 2010 08:01 PM |
|
Please find attached your example script. I put in some comments to explain what it does. Note that the sorting of grid 1 and 2 is altered due to the binary search in the find in grid action. The great thing about the binary search is that it's fast. You can put a many records in grid 1 and grid 2 and your schema with buy, sell and keep will be calculated with lightning speed. Tijn |
compare_grids.zip
|
|
|
|
|
  |
 |
 |
 |
|
|
|
|