Turning a .txt file into a wave

I want to upload a .txt file as a 1 column wave, this is what I have so far, I am not sure what the next steps would be. I have attached the .txt file that I am trying to upload.

NewPath/O dataFolder
String callist=ListFilesofType("dataFolder",1,".txt")
String timefile=StringFromList(0,callist)
LoadWave/G/M/D/A=wave/P=datafolder timefile


Thanks
spot2.txt (5.72 KB)
From "I want to upload a .txt file as a 1 column wave", I am guessing that you want to concatenate all of the columns in the matrix wave created by LoadWave/G/M into a single 1D wave. After LoadWave/G/M, you can use Redimension to convert the wave to 1D. Something like:


	String name = StringFromList(0, S_waveNames)	// Get name of the wave created by LoadWave
	Wave w = $name	// Create a wave reference
	Variable numRows = DimSize(w, 0)
	Variable numColumns = DimSize(w, 1)
	Variable numPoints = numRows * numColumns
	Redimension/N=(numPoints) w


BTW, when you post Igor code, use <igor> and </igor> tags as explained at http://www.igorexchange.com/node/3221
It still is not working, I keep getting an error message that states: while executing LoadWave: no data was found in file.

 Function Loadtimeaxis (cwl) 
	Variable cwl
	NewPath/O dataFolder //dialog box to get the data folder path
	String callist=ListFilesofType("dataFolder",1,".txt")
	String timefile=StringFromList(0,callist)
	LoadWave/G/M/P=datafolder timefile
	String name = StringFromList(0,timefile)	// Get name of the wave created by LoadWave
	Wave w = $name	// Create a wave reference
	Variable numRows = DimSize(w, 0)
	Variable numColumns = DimSize(w, 1)
	Variable numPoints = numRows * numColumns
	Redimension/N=(numPoints) w
End
I keep getting an error message that states: while executing LoadWave: no data was found in file.


Although my web browser makes it look like your file contains numbers in columns, in fact, it contains one long row of number separated by tabs.

You can't use LoadWave/G for this data. To understand why, execute this:

DisplayHelpTopic "Loading General Text Files"


You can use LoadWave/J (Load Delimited Text). Here is a function that may get you started in the right direction:


Menu "Load Waves"			// Add to Load Waves submenu
	"Load Time File...", LoadTimeFile("", "")
End

Function LoadTimeFile(pathName, fileName)
	String pathName		// Name of an Igor symbolic path or ""
	String fileName			// Name of file or full path to file

	// First get a valid reference to a file.
	if ((strlen(pathName)==0) || (strlen(fileName)==0))
		// Display dialog looking for file.
		Variable refNum
		String filters = "Text Files (*.txt):.txt;"
		filters += "All Files:.*;"
		Open/D/R/P=$pathName /F=filters refNum as fileName
		fileName = S_fileName			// S_fileName is set by Open/D
		if (strlen(fileName) == 0)		// User cancelled?
			return -1
		endif
	endif

	LoadWave/J/M/P=$pathName/Q fileName
	String listOfWaves = S_waveNames		// S_waveNames is set by LoadWave
	String filePath = S_path + S_fileName	// S_path and S_fileName are set by LoadWave
	
	String name = StringFromList(0, listOfWaves)
	Wave w = $name					// Create a wave reference

	// Redimension as 1D wave
	Variable numRows = DimSize(w, 0)
	Variable numColumns = DimSize(w, 1)
	Variable numPoints = numRows * numColumns
	Redimension/N=(numPoints) w
	
	Printf "Loaded wave %s from \"%s\"\r", name, filePath
	
	return 0	// Success
End


To clarify what a symbolic path is versus a data folder, execute these commands:

DisplayHelpTopic "Symbolic Paths"
DisplayHelpTopic "Data Folders"