Generate Report Separator Character
-
I am trying to write a application to manipulate the CSV report generated by Generate Report. The problem that I have encountered is that when functions that have multiple arguments (i.e. animate) are included in the OnClick attribute, the parser I use does not handle the field correctly due to the extra commas. The same is true for descriptions that have commas. I'm sure that I could eventually work out a modification to the parser to fix this, but was wondering if there is a way to change the separator character used by Generate Report? In the past I have used "~" as the separator character when I was not in control of what the user could enter as data. Thus far, I haven't run into a problem with this since "~" is seldom used in American English. Any ideas out there?
-
Hey Dik,
Couple of options for you:
- See if you can find a better parser. The CSV that we output uses the "double quote as escape character" csv approach, so the output will look like this:
"Value1","Value2","Value3","animate(""material"",""red"",""blue"")"
Note that the quote characters inside the 4th value are double quoted to indicate that they're not termination characters. Your parser needs to be able to recognize that the commas inside 4th values are not separators since they're inside single quotes.
- Write or hire someone to write a custom Ruby exporter that does what you need. If you end up going down this road, feel free to PM me and loop me into the conversation. I could share some Ruby code that generates a simple report.
Cheers,
Scott Lininger
SketchUp Engineer -
You could try this:
"Value1","Value2","Value3","animate(""material"",""red"",""blue"")"
Remove the leading and closing " and swap any (" or ") for ( or )
Value1","Value2","Value3","animate(material"",""red"",""blue)
Split using "," and immediately join with ,
Value1,Value2,Value3,animate("material","red","blue")
Split again using "","" and join with say ~ (or perhaps better | ?)
Then you have a list that is , separated...
Value1,Value2,Value3,animate(material|red|blue)
Now you can go through each entry...
If the entry contains | then strip the trailing ) and then split using (
E.G. you now have 'animate' and 'material|red|blue'
The later part can now be split using | to get the values...If you know the value with multiple fields will be called 'animate' then it's even easier...
. -
Thanks TIG, I'll walk that through some sample data and see what I get. Unfortunately, I'll have no idea what might be in the data file. If I could control that, life would be easier.
Edit: Sorry to report, but it failed on the first two sample files. There is a lot more variability than in the example that Scott gave.
-
Dik,
See attached for an example script for creating reports from Dynamic Component attributes. We tried to make it as instructive as possible, but please feel free to ask questions.
I'll ask Simone, who wrote the script, to jump on this thread to help.
-
Here I am ready for input and light criticism.
Hope this helps and makes it easy for you to modify this for your own purpose.
thanks.
Simone. -
In the Ruby Example I gave you should be able to easily add/modify the csv format to use a different separator.
Change the following variables in the script to look like this
@cell_mid = "~"
@cell_end = "~"Put the script in the Plugins directory start SU7 and ta-daaa!
And there you should have it.
Hope this helps.
Simone. -
Thank you Scott and Simone!
I'll jump on this as soon as I can.
Advertisement