Export Query Data to a CSV File
Data from a query can be exported to a CSV file, which can be used by other programs.
Note:
This option has the following known limitations:
- Precision on DateTime objects may be lost.
- Any string with a new line or a comma will break the CSV columns.
- Cognex recommends performing tests to ensure accuracy before deploying.
The following code illustrates how to implement this functionality, using the OnClick script point of a Button element on a Page:
Copy
$Databases.FastDatabase.Results.GetRecent.Run();
var data = $Databases.FastDatabase.Results.GetRecent.DataSet.GetDataCsv();
string path = @"C:\path\to\output.csv";
System.IO.File.WriteAllText(path, data);