How do I export block group table to csv using perspective

I am new to scripting. I have tags in a block transaction group. I like the way the table looks with my tags. How do I configure my export to .csv button on page view to use the date range and pull the data from table to export to csv. I know my file location works because we have another page that is setup similar, only they had the script make the .csv columns and rows. I just need to pull the data from table I created. I would also like to show some of the table data on a page if possible. I’ve tried multiple things and its not working.

How do transaction groups play into this? When you say table do you mean the transaction group configuration?

Transaction group implies that the data is being stored in a database, so presumably you would need to somehow query the database for the data and then through one of a few methods convert that data to a .csv.

However, note that perspective doesn’t have direct access to the users file system so you will also need to prompt the user to download the file, if that is the intention you are after.

It is not as simple as just converting tags subscribed to a transaction group to a .csv file, and the true intent of your application will change the method that could/should be used.

Please show some of what you attempted and what you got. Please post code as text, then use the "preformatted text" button </> to make it look good. Please use your computer's screen capture tool instead a camera for screenshots. (Almost impossible to avoid those moiré patterns with a camera.)



Here is a few pictures showing where i’m at. Right now I would atleast like to call and export the whole Wrap_Temps2 query and then work on the start and end dates after I get that working. Any help would be great. I apologize I’m new to scripting. I can only post 3 pics at the moment. I have another that shows an existing view in program that is similar, only they used script to build the .csv with historical tags.

Were you able to check out my screenshots

  1. The script you have provided is incomplete. You are missing the ) on line 7.
  2. Your script will not run, because your named query is configured with 2 parameters (even though you aren’t using them.) On top of that, the parameters argument is not optional and must be included even if you only supply an empty dictionary.
  3. When called from a gateway scope, the project name must also be supplied to the function.

Something like this:

data = system.db.runNamedQuery('EggLife','Line 2/WrapTemp',{'myValueX':None,'myValueY':None})
csv = system.dataset.toCSV(data)
system.file.writeFile(r'\\IGNITIONPROD\History\stackerHist_')

Also, please use the pre-formatted text option </> to post script. That way those who are trying to help can easily read and work with it.

Still does not work, maybe its the file location now.

As I said earlier. Perspective does not have direct access to the users file system.

If your desire is to download this file to a client's workstation you will have to use the system.perspective.download() function.

In you first post you mention a transaction group and a table, however, you haven't show either. How does that tie into whatever it is you're trying to accomplish?

Got it. Thank you!!! Now I need to add my timestamp row. I should be able to get it from here. Thank you thank you


When I export to .CSV the timestamp does not look right, but when you open with notepad it is there. Any ideas for getting the .CSV to show correct timestamp?

You need to set the format for the column in excel. That is an excel problem. Ignition is only creating a CSV file, which does not contain any encoding for formatting.

1 Like

I added a boolean tag to use as my trigger for this transaction block group. I made the tag read-only and it will not show up to select the tag to be a trigger

I don’t believe that you can use a Read Only trigger in conjunction with the Reset trigger after execution flag, since by definition you need to write to the item.

If you un-check “Reset trigger after execution” or change your trigger item to allow writes does it allow you to select the item?

@Paul.Scott Do you know if there is any documentation about the different requirements for trigger items based on the selected flags? I couldn’t find anything but admittedly I also didn’t look very hard.

Apologies for the delay, was out of office.

@Levi_Overmyer (and anyone else, in the interest of posterity) the issue is that block items can't be triggers. So you'd need to delete the trigger item you added under the "Block Items" heading, and instead drag it under the Basic OPC/Group Items heading. Once you do you should see something listed under the "Trigger on item" dropdown.

The description for the Trigger on item setting did say that Basic OPC items and Expression items could be triggers, but didn't make it clear that block items were exempt, so we're adding something. Thanks for letting me know!

2 Likes