Exporting Data to CSV file


Recommended Posts

I'm trying to export data from a SQL query using a export set. Row names appear, however I'm getting empty cells instead of values, except time.

Also, my SQL table has 7 rows and only one row is created on the file.

Into the Export Set properties I have set:

Main tab:

Export Method: ASCII Delimited

File name: variable via sequence

Details tab:

Mode: Fixed interval

Inerval: 300

Type: Snapshot

Time sig figs: 9

Use excel time: 0

Delimited by: ;

Include Headers: 1

Header File: 0

Existing File: Overwrite

The code is the following:

		 //sChanPrefixes is an array of the channels' names
		 for (private.x = 0, x < numrows(sChanPrefixes), x++)
			private string sNoGrandeza = sChanPrefixes[x] + "_" + DoubleToStr(Curnet) + "_" + DoubleToStr(Device)
			private string sGrandeza = "result."+ sChanPrefixes[x] + "_" + DoubleToStr(Curnet) + "_" + DoubleToStr(Device)
			//Export to csv
			Export.CSVExport.AddExpression(sNoGrandeza, sGrandeza,9)

Link to comment
Share on other sites

Two things:

1) is result a global? It needs to be for the export set to have access.

2) presumably the member variables of result don't have time, so the export set doesn't really work properly. You need to assign time to each one of the variables you are exporting.

That all said, you are better off using the file. functions to simply write the data yourself. Export sets are designed to make basic logging easy, but you are beyond basic logging because of your data source, so you might as well use script and get total control.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.