Save Table Copy - Help

toledoeng
Posts: 1
Joined: 2009-02-03
Location: United States

I am attempting to automatically create and save out (tab-delimited txt file) a table comprised of the results of an Igor procedure. The results are within a subfolder of the original waves and there are many result files. I would like all of the result files to be placed inside the same table/file for subsequent analysis outside of Igor. I tried to do this by simply finding the subfolder using the data browser, setting that as my current data folder and running a procedure similar to the example in the displayhelptopic for "savetablecopy".

//for example savealltables ("_none_"," ")
// "_none_" is used since the files are inside the current data folder
 
 
Function savealltables(pathName, fileName)
	String pathName		// Name of an Igor symbolic path.
	String fileName
	String tableName
	Variable index
	index = 0
	do
		tableName = WinName(index, 2)
		if (strlen(tableName) == 0)
			break
		endif
		SaveTableCopy/P=$pathName/W=$tableName/T=1/A=1 as fileName
		index += 1
	while(1)
End

When I run this procedure it creates a blank txt file. What am I doing wrong? The only way I can get the results in the file is if I create a new table within Igor containing all of the results, then running the save procedure. However, if I have to create the table using Windows>NewTable I might as well save it out using File>SaveTableCopy. I am trying to streamline the steps as much as possible since I am dealing with large batches of files.

Any help would be appreciated.


Posts: 906
Joined: 2007-06-21
Location: United States

The term "table" in SaveTableCopy refers to an Igor table window that you have created. SaveTableCopy saves the text in the Igor table window to a file.

I get the feeling that you want to save the contents of all of the waves in the current data folder to a file. For that you need to create a list of wave names and then save it using Save/J. /J means "delimited text". Here is a crack (untested) at what I think you want to do:

Function SaveAllWavesInCDFAsText(pathName, fileName)
	String pathName
	String fileName
 
	// Create semicolon-separated list of all waves in current data folder
	String list = ""
	Variable numWaves = CountObjects(":", 1)
	Variable i
	for(i=0; i<numWaves; i+=1)
		String name = GetIndexedObjName(":", 1, i)
		list += name + ";"	
	endfor
 
	// Save waves as tab-delimited text
	Save/J/B/P=$pathName/O list as fileName
End


Back to top