Save Delimited Data with CSV file extension

Hi,

 

I would like to save data with the .CSV file extension for latter loading into Excel (client request - don't understand why).

 

If I try to save a delimited file I am forced to use .txt file extension.  The issue is Excel does not understand that .txt is a csv file and loads it as general text not columns of data.  If I change the file extension to .csv then Excel recognizes it properly.

 

How do I avoid the extra step of having to manually rename the file?

 

Andy

In reply to by hegedus

>If I try to save a delimited file I am forced to use .txt file extension.

I don't get the "You cannot save this document" dialog on MacOS 10.13.2. Either Apple has changed something or you have a different setting somewhere. What version of MacOS are you using?

If I choose Data->Save Waves->Save Delimited Text in Igor7 or later, in MacOS 10.13.2, I can choose All Files from the file type popup in the Save File dialog and then save as <filename>.csv. On Windows I don't need to choose All Files.

If you are saving programmatically, here is an example of saving programmatically as .csv and presenting a Save File dialog to the user:

Function/S DoSaveFileDialog(proposedFileName)
	String proposedFileName		// e.g., "File.csv"

	Variable refNum
	String message = "Save a file"
	String outputPath
	String fileFilters = "CSV Files (*.csv):.csv;"
	fileFilters += "All Files:.*;"

	Open /D /F=fileFilters /M=message refNum as proposedFileName
	outputPath = S_fileName

	return outputPath		// Will be empty if user canceled
End

Function SaveWaveAsTextInteractive(w)
	Wave w

	String fileName = NameOfWave(w) + ".csv"
	String outputPath = DoSaveFileDialog(fileName)
	if (strlen(outputPath) == 0)
		return -1
		// User cancelled
	endif

	Save/J/M="\r\n" w as outputPath
End

 

Mac 10.13.5

 

If I change the popup to all files, then I can save as .csv.  Is there a way to force the save dialog to default to all files?

 

Andy

In reply to by hegedus

Quote:
If I change the popup to all files, then I can save as .csv.  Is there a way to force the save dialog to default to all files?

Only programmatically, using:

String fileFilters = "All Files.*;"

But since you know you want to save as CSV, you may just as well use: 

String fileFilters = "CSV Files (*.csv):.csv;"