LoadWave Combining Date and Time
The snippet loads the following data file:
dist_1:BL_XAS
Datum;Zeit;Z[mm];I1;I2;I3;I4
27.05.2010;09:00:00;9.37;0.00;0.00;0.00;0.00
27.05.2010;09:00:10;9.30;0.00;0.00;0.00;0.00
27.05.2010;09:00:20;9.28;0.00;0.00;0.00;0.00
27.05.2010;09:00:30;9.18;0.00;0.00;0.00;0.00
27.05.2010;09:00:40;9.09;0.00;0.00;0.00;0.00
The snippet illustrates several techniques such as using the LoadWave/B flag to specify wave names, handling a special column separator (semicolon in this case - /V flag), specifying the date format (/R flag) and combining date and time after loading.
The first two lines are ignored. The names are hard-coded into the loading routine. After loading the waves, the date and time wave are combined and the time wave is killed.
Menu "Load Waves"
"Load Mangold File...", LoadMangoldFile("", "") // Display Open File dialog and load one file
End
Function LoadMangoldFile(fileName, pathName)
String pathName // Name of symbolic path or "" for dialog
String fileName // Name of data file or "" for dialog
Variable refNum
// First get a valid reference to a file.
if ((strlen(pathName)==0) || (strlen(fileName)==0))
// Display dialog looking for file.
Open/D/R/P=$pathName/M="Select Mangold data file" refNum as fileName
fileName = S_fileName // S_fileName is set by Open/D
if (strlen(fileName) == 0) // User cancelled?
return -1
endif
endif
String columnInfoStr = "N=Datum,F=6;N=Zeit,F=7;N=Zmm;N=I1;N=I2;N=I3;N=I4;"
// /J specifies Load Delimited Text
// /A means "auto-name & go" (don't display dialog asking user to confirm column names)
// /L says the first data line is line 2 (zero-based)
// /V sets the column separator as semicolon
// /B sets column names and formats
// /R sets the date format
LoadWave /P=$pathName /J /A /L={0, 2, 0, 0, 0} /V={";", "", 0, 0} /B=columnInfoStr /R={German,2,2,2,2,"DayOfMonth.Month.Year",40} fileName
if (V_flag < 7)
Print "User Cancelled or Error Occurred"
return -1;
endif
Wave Datum, Zeit
Datum += Zeit // Add time to date
KillWaves/Z Zeit // We don't need time anymore
String title = ParseFilePath(3, S_fileName, ":", 0, 0) // Remove extension from file name
Edit /W=(9,47,674,304) Datum, Zmm, I1, I2, I3, I4 as title
ModifyTable format(Datum)=8, width(Datum)=120
End
Forum
Support
Gallery
Igor Pro 10
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More
May 30, 2010 at 09:55 am - Permalink