Loading waves from csv consist of random number of text and data

Hi, I am newbie to the Igor.
I have a csv data file that contains various number of texts and data.
I tried to load it with every function in Igor, but I cannot pick it up.

can any experts suggest some way to load it?
I attach the example of my data.

Thanks you so much
example_0.csv (81.03 KB)
This command loads the "DataValue" columns:

LoadWave/J/D/E=1/L={0, 216, 0, 1, 3}


To understand what it is doing, execute this:

DisplayHelpTopic "Loading Delimited Text Files"

and

DisplayHelpTopic "LoadWave"


To load the other information, if you want it, would require that you write a custom file loader. This would require a fair amount of Igor programming skill.
As Howard notes, the short answer is ... The ability to load the data you have is not built in to Igor. It needs to be programmed.

When you need to get the data in to Igor right away, the fastest method might be ...

* load the data file in to a spreadsheet
* copy the three columns of data to a separate worksheet by themselves
* export just that worksheet as a CSV file
* load the data in to Igor

You could also copy the worksheet directly in to a table in Igor. Or, you could import the spreadsheet directly in to Igor.

Someone here may eventually be willing to provide you with the Igor code for a basic file loader to get you started. Another option is to determine whether your instrument can export just the data without all the extra text stuff.

--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
What I usually do is to load a file like that as one long text wave, identify the information I need, and then reload that relevant part as a numeric wave. Try the example below with your file. The tables are only meant as a help while figuring out which part of the file to load.


Function Test()

	//	Creates a path to "D:Temp:" I am lazy and that is where I placed the file.
	NewPath/Q/O/Z CSVDataPath "D:Temp:"

	//	Will use CSVDataPath with the next Open command. This is identical to Open/P=CSVDataPath, but it prevents a bug in Igor 6.36 or, most likely, Windows 10
	PathInfo/S CSVDataPath

	//	Display an open file dialog, showing only files with the extension .csv
	String FileExtension="CSV Files (*.csv):.csv;All Files (*.*):.*;"
	Open/D/F=FileExtension /R/MULT=0 /P=CSVDataPath RefNum
	String FullFileName=S_FileName
	
	//	Checks that a file was actually selected
	if (StrLen(FullFileName)!=0)
	
		//	Loads the file as a one long text wave
		LoadWave /O/N=LoadedTextWave /K=2 /Q /J /M FullFileName
		Wave/T LoadedTextWave=LoadedTextWave0
		Variable NumberOfLines=DimSize(LoadedTextWave, 0)
		
		//	Creates a table with the loaded text wave
		DoWindow/K LoadedTextTable
		Edit/N=LoadedTextTable LoadedTextWave
		
		//	Searches the first column for "DataValue"
		Duplicate/O/FREE/R=[][0] LoadedTextWave, Loaded1stColumn
		FindValue /S=0 /TEXT="DataValue" /TXOP=5 /Z Loaded1stColumn
		
		if (V_value!=-1)
	
			//	Loads DataValue part the file as a three-column numeric wave
			LoadWave /O/N=LoadedNumericWave /K=1 /L={0, V_value, NumberOfLines-V_value, 1, 3} /Q /J /M FullFileName
			Wave  LoadedNumericWave=LoadedNumericWave0

			//	Creates a table with the loaded numeric wave
			DoWindow/K LoadedNumericTable
			Edit/N=LoadedNumericTable LoadedNumericWave
		endif
	endif
end
This is a basic file loader I use to import data that is organised in a similar way, i.e. a header followed by numeric data.
The loader reads the data first line by line to find a keyword (defined here as string constant "DataKey"), which separates header and data. The line number where this occurs can be used for the subsequent LoadWave command. Attached is also an example text file. You may be able to adjust this to your needs if you inspect the file and the code below.


strConstant DataKey = "*SPECTRUM*"
strConstant EnergyKey ="*XPERCHAN*"

function LoadEMSA()
	variable refNum
	Open/D/R/F="*.txt" refNum 
	if (strlen(S_FileName) == 0)
		return -1
	endif
	Open/R refNum as S_fileName
	
	string wNote=""	
	variable i=0
	variable Scaling, DataStart	
		
	do
		// read file line by line
		string line
		FReadLine refNum, line
		if(strlen(line) == 0)						
			break										
		endif
 		
 		// save header line to string 
 		wNote += line
 		
 		// extract value for x-scaling
 		if(StringMatch(line, EnergyKey))
			sscanf line, "#XPERCHAN    :%f", Scaling
 		endif
 		
 		// stop reading when DataKey is hit
		if(StringMatch(line, DataKey))
			DataStart = i+1
			break
 		endif
		i+=1
	while(1)
	Close refNum
	
	// load the spectral part of the data, scale wave and add header as wave note
	LoadWave/B="N='_skip_'; N=Counts;"/O/A/G/D/L={0,DataStart,0,0,0} S_fileName
	wave Counts	
	SetScale/P x 0, Scaling, "keV", Counts
	Note/K Counts, wNote
	return 1
end
Anorthite.txt (30.77 KB)
jjweimer wrote: The ability to load the data you have is not built in to Igor.

While data loading could certainly be simplified in Igor, this is not entirely true. From the Data menu, choose "Load Waves - Load Waves...". In the dialog, choose file type Delimited Text, and click Tweaks. For your specific file, you'll have to enter 215 for "Line containing column labels" and 216 for "First line containing data." That should load your data. It also prints out the actual command used in the history (the path will be specific to your computer):

LoadWave/J/D/W/K=0/L={215,216,0,0,0} "path:example_0.csv"
That depends on how you define "data".
The 'information at the end of the file in a tabular form' can be loaded that way. The 'additional information about the experimental conditions' cannot be loaded directly into variables (into a text wave is possible though).
HJ
Thanks everybody.
It is helpful to me a lot.
I start with the way you guys suggested.

I just loaded them by copy and paste, but the advanced method might be needed for the batch analysis.
Thanks for great help and will post the result.