CSV export from PowerChart in Perspective : Changing the separator

Hi,

I've been having trouble with figuring out how to change the separator used for the PowerChart export to CSV.

The users of our gateway can have either comma or semi-column as a separator in their windows region setting. Most of these people also strictly use the PowerChart tool for their need. They then often convert these to csv to (try to) incorporate in their Excel charts. The conversion step required (adding "sep=,") at the beginning can be a bit overwhelming for some of them.

I figured: No problem I'll setup a script with 2 buttons. I can easily get my datasets from a regular chart or graph and add the required code with:

chart = self.getSibling("chart")

data = chart.props.data

csv = system.dataset.toCSV(data)

formating = "sep , \n"

formatedcsv = formating + csv

system.file.writeFile(...)

But I can't find the way to get the data from a PowerChart in the same way. There might also be a way to change the option directly from the properties of the chart, but I wasn't yet able to find it.

Any tip or ideas to help me figure this one out? Thank you in advance.

Perhaps you should be using system.dataset.exportExcel()? Avoid the locale problem entirely?

Edit: See note below.

Sadly I still need the dataset from the PowerChart to do this.
I might be able to reach it in Props/Pens/X/Data but that would still give me only one column. Is my only solution a "for" to check all of them for data and rebuild the dataset column by column at that point?

Yes, you will need to iterate to construct the dataset, or perhaps construct a series of datasets. (You can pass multiple datasets to .exportExcel() .toExcel().)

Except this is for Perspective, and .exportExcel() is Vision Client scope only.

2 Likes

Whoops! I mixed that up with system.dataset.toExcel. Use .toExcel(). Combined with system.perspective.download().

1 Like

Thanks for the replies. I'll figure something that works with the .toExcel() and then post the working script when done.