Reading Datasets, getRowIndex

Hey Ignition Community

trying to find a way to get the row index if I know the value of a specific column.

Example, column 0 is a sequence number, the column 1-15 are the instructions for that specific sequence. I know I'm on sequence 100, but I don't know that its in row 0. Is there any way to get that value of 0?

Can you post an example dataset?

Well, the short answer is "it depends".

Datasets are not necessarily ordered, and this almost always extends back to the data source. There are many techniques that could be used to find what row a cell in a particular column has a certain value, but unless you have otherwise enforced it, there is nothing that guarantees that value to be unique.

My first question would be how are you trying to access this data such that you know the value at a row and column, but you do not know the row number?

In a binding, I would generally use my where() expression function to spit out the matching row. (In my Integration Toolkit.)

process engineering gives me a task list in excel, I would then populate a dataset off that file. The Sequence number is kinda like a primary key for SQL. The Seq number would be updated by the PLC, then I would populate a UDT with all the data that would be corresponding to that seq number

Is there a reason you can't just use SQL?

IT, dont have a DB and am very restricted on getting one made

Oy! Then you really need my toolkit.

Ignition without a DB is like using paper cups with string instead of telephones and networks.

3 Likes

Using Ignition without a database is like buying a Ferrari but not wanting to put tires on it.

3 Likes

I have some "Standard" DBs that they created. Useful but not flexible on making new tables. If this idea fails then I would go down the route of forcing them to make me a new table

Are you forbidden to use the designer's query browser to make a table?

mostly likely not, might have to give that a try and hope they don't notice

Their policy might be hiding the fact that they don't really know what they are doing. In which case your actions are unlikely to be noticed. Developing in Ignition without DBA privileges is like being handcuffed.

2 Likes

man you're telling me. I'm a controls guy who's not allowed to have admin right on my local.

I assume that you're using:

system.dataset.fromCSV() to create a dataset from the file you're given?

If that is so, then you could do something like this:

data = system.dataset.toPyDatSet(excelDataset)
seqNum = 100
rowIndex = 0
for i,v in enumerate(data.getColumnAsList(data.getColumnIndex('SeqNum'))):
    if v = seqNum:
        rowIndex = i
        break

print data[rowIndex]

It goes without being said, that a DB will make this much much easier and is the preferred method. Especially considering that you mention that you want to then push these values out into a UDT. I would strongly recommend that you do any scripting like this in a Gateway Event Script.

This used to be the same with me, didn't take long for them to get tired of me calling them just to log in and watch me correct the issue. But if they hadn't yielded, I would have been gone a long time ago.

I'd quit that job so fast it'd make their heads spin.

It's probably just as well that I'm solo and do my own IT.

2 Likes

just getting total number of rows

I would if the benefits and it wasn't a 5 minute commute

That's the normal printed representation of a row object.