extract csv data from visualization

#get list of filtered rows
dataTable = Document.ActiveDataTableReference
rows = Document.ActiveFilteringSelectionReference.GetSelection(dataTable).AsIndexSet()

#Script configuration
delim = ","
rowDelim = "\n"
docProperty = "myDocProperty"

#generate CSV
csv = ""
for column in dataTable.Columns:
   csv += column.Name + delim

csv += rowDelim

for r in rows:
   for column in dataTable.Columns:
      csv += column.RowValues.GetFormattedValue(r) + delim
   csv+=rowDelim

#show results
print csv
Previous
Next Post »