Hello Ventuzians!
THE FORUMS ARE CLOSED!

Please join our discord server HERE!! << click me :D

We are shutting our Ventuz Forum, but don't worry, it will all be archived for you to search in if you have a query. From now on, please add all your comments, questions or observations into our Discord Server

Thanks for the great time - see you on discord!!
Dee, Karol, Daniel and the whoooole Product and Support team!

Sort numbers from excel file

Q and A about functionality and how to solve a special task for your application.

Moderator: Support

ahmedahmed1223
Posts: 45
Joined: 07 Jan 2017, 14:02

Sort numbers from excel file

Post by ahmedahmed1223 » 05 May 2017, 21:17

hi there
Is there any simple way to sort numbers from small to big imported for example from excel sheet or text file?
also how to sort the numbers is there text linked to it? like team A score 50 point. Team B score 20 point etc. :?:


ahmedahmed1223
Posts: 45
Joined: 07 Jan 2017, 14:02

Re: Sort numbers from excel file

Post by ahmedahmed1223 » 06 May 2017, 19:38

I have think about this option ,but I need to sort values in ventuz not office.
So is there any tools in ventuz can do the job ?

Christian Krix Schmidt
Posts: 290
Joined: 18 Jan 2012, 11:36
Location: Dubai, United Arab Emirates
Contact:

Re: Sort numbers from excel file

Post by Christian Krix Schmidt » 06 May 2017, 20:18

That is a very specific task and usually needs to be customized to fit a specific need. You can use the C# node, input the values in it in an array and then sort the array there and output the values again. It's only a few lines of code to get it done. There is a C# array sort method for specifically that usage. https://msdn.microsoft.com/en-us/librar ... .110).aspx

ahmedahmed1223
Posts: 45
Joined: 07 Jan 2017, 14:02

Re: Sort numbers from excel file

Post by ahmedahmed1223 » 06 May 2017, 20:39

thanks u-double-u and Christian Krix Schmidt but I am not programmer.
To be honest I need to recreate this scene in ventuz :D
https://youtu.be/RamDBQHU3tU?t=6m26s
It was created in other cg software I think.
So is there any other ideas ? :?:

Christian Krix Schmidt
Posts: 290
Joined: 18 Jan 2012, 11:36
Location: Dubai, United Arab Emirates
Contact:

Re: Sort numbers from excel file

Post by Christian Krix Schmidt » 07 May 2017, 03:43

Oh my. That is a really complicated setup in that example for just 5 values. What if you have to sort 10 or 20 values?
So the best way of doing this - and being able to have any number of numbers/names to sort would be to use a little C# script. Would be perfect.
Without a script you could read out every cell and then start sorting them manually using little expressions. A lot of nodes for a very limited number of entries.

I would recommend a really simple alternative. Bind the Excel cells with the names fixed. First row in Excel is first row in Ventuz, 2nd is 2nd, etc. for all your names.
Go into Excel. You will be editing it anyway. Select all your names and values. From the Excel Data menu select Sort. Select which Column you want to sort by and the order of the output. Click OK. Press Save and Ventuz is updated as well.
Attached is a screenshot of Excel with the Sort menu open. Super simple and quick. No logic required in Ventuz.

Hope that helps to solve your problem.
Chris
Attachments
ExcelSort.jpg

ahmedahmed1223
Posts: 45
Joined: 07 Jan 2017, 14:02

Re: Sort numbers from excel file

Post by ahmedahmed1223 » 07 May 2017, 21:58

Thanks Christian ,
but i need to do the sorting thing in ventuz not in excel.
So is there any suggestion about ventuz Tools that can help in doing this scene?

Christian Krix Schmidt
Posts: 290
Joined: 18 Jan 2012, 11:36
Location: Dubai, United Arab Emirates
Contact:

Re: Sort numbers from excel file

Post by Christian Krix Schmidt » 07 May 2017, 22:50

Anything besides a script is equally cumbersome and limited like the Expression example in the youtube video. The best way is to open the Excel file in C# and parse it. I can highly recommend you either learn a bit about scripting or find someone who can help you with that. In the meantime, I created a rough solution for you. Attached is an archive with scene and Excel file. The scene reads out 8 rows of values and names from an Excel manually. I never programmed an Excel connection in C# and I didn't want to learn it just for this example. So I used regular nodes to read the data from Excel. That should make things easier for you as well. And there is a little C# script which sorts the data and outputs the result. The script is super basic and probably not very well coded. Doesn't really matter. It gets the job done. With the basic setup done you should be able to extend it if you need more than 8 values.

Hope that helps with your project.
Chris
Attachments
ExcelSort.vza
(18.42 KiB) Downloaded 205 times

ahmedahmed1223
Posts: 45
Joined: 07 Jan 2017, 14:02

Re: Sort numbers from excel file

Post by ahmedahmed1223 » 07 May 2017, 23:11

thanks Chris :D

User avatar
Eric_RD
Posts: 103
Joined: 04 Jun 2014, 14:01
Contact:

Re: Sort numbers from excel file

Post by Eric_RD » 09 May 2017, 16:24

I haven't read everything but:
you can sort an Array without a script:
macke a new string expression
Edit custom Model->delete all inputs->create a new float array input named "NumbersArray"->create a bool Input named "Reverse".
add the following text as expression (including the brackets)

Code: Select all

{
Array.Sort(NumbersArray);
if(Reverse)Array.Reverse(NumbersArray);
return String.Join("\r\n",NumbersArray);
}
create a string splitter node and connect it to the output of the string expression
connect you array (int or float) to the NumbersArray of the string expression
works as well for string arrays (just change the float array to string array)
done
you now have a sorted array and with the reverse bool you can set it from ascending to descending

Post Reply