Description This function writes the datum collected by a data collector surface to a CSV file.
Syntax nDatum = DataCollectorSurfWriteCollectedDataFile( surf, fileName )
Parameters nDatum (Long) Returned number of lines (datum+1, for header) written to the output file. If the file could not be written, nDatum = -1.
surf As Long Node number of the data collector surface whose datum are being written to a CSV file.
fileName As String Full file path name, including *.CSV extension, where the data file will be written. Ex. "C:\temp\collectorData.csv"
Example The example below demonstrates how to write the datum for each data collector surface object in the model out to a CSV file on disk.
Sub Main
Dim outDir As String, outFile As String outDir = GetDocDir() & "\"
Dim nDatum As Long Dim curNode As Long For curNode = 5 To GetEntityCount()-1 'Is the current entity a surface? If IsSurface( curNode ) Then 'Is the current surface a data collector? If IsDataCollectorSurf( curNode ) Then 'Is the data collector set to collect data? If DataCollectorSurfIsCollectData( curNode ) Then 'Is the data collector initialized? Doesn't guarantee non-zero data has been collected. If DataCollectorSurfIsDataAvailable( curNode ) Then
outFile = GetFullName( curNode ) & ".csv" nDatum = DataCollectorSurfWriteCollectedDataFile( curNode, outDir & outFile ) If nDatum > -1 Then Print "Datum for surface " & GetFullName( curNode ) & " saved to file." End If
End If End If End If End If Next
End Sub
See Also Data Collector Surface Scripting DataCollectorSurfGetDatumCount DataCollectorSurfIsCollectData DataCollectorSurfIsDataAvailable DataCollectorSurfReadCollectedDataFile DataCollectorSurfSetCollectData
|