help to import text-format data into igor
wwzhang2
1 //experiment number
1 //pattern number
1 //repeat number
text of condition
44 //this is the real data
155
155
155
...
23
1 //experiment number
1 //pattern number
2 //repeat number
...//repeats
1 //pattern number
1 //repeat number
text of condition
44 //this is the real data
155
155
155
...
23
1 //experiment number
1 //pattern number
2 //repeat number
...//repeats
My question is I want to import the data as waves and name the wave as experimentNumber_patternNumber_repeatNumber, but when I try to use "load general text" option, it doesn't work that way. Any suggestion?
This is quite complicated and is not going to be easy to implement.
You are going to need to read the header data, create your desired wave name, and then in a separate operation load the wave data.
Since you have multiple data sets in a file, each with its own header information, you will need to do this in a loop.
If the header information (experiment number, pattern number, repeat number) is deterministic then you don't have to read it from the file but instead you can generate it using loop variables.
If the header information is not deterministic you will have to read it from the file using either FReadLine or LoadWave.
Here is an example of reading header data and then loading wave data:
http://www.igorexchange.com/node/908
For a more detailed example using FReadLine see
http://www.igorexchange.com/node/880
Instead of using FReadLine to read the header data you could use LoadWave/J/L={0,startLine,3,0,1} which loads the first three lines of the first column only. This will create a numeric wave containing your experiment number, pattern number and repeat number.
You will have to determine startLine yourself either by a-priori knowledge or by counting the lines in each section in a separate step. It is the starting line of a section in the file - the zero-based line on which the experiment number appears.
For loading the actual data you will need to use /L again to tell LoadWave/J to skip the first 6 lines:
You will have to figure out numLinesToLoad yourself either by a-priori knowledge or by counting the lines in each section in a separate step.
After reading the experiment number, pattern number and repeat number, you will create a string variable containing the desired wave name, something like this:
sprintf name, "E%d_P%d_R%d", experimentNumber, patternNumber, repeatNumber
where you have determined experimentNumber, patternNumber, repeatNumber either by a-priori knowledge or by reading the file.
Once you have the name string variable you can use it with the LoadWave /B flag to set the wave name:
LoadWave/J/L={...}/B=columnInfoStr
This is quite doable if you have reasonably good programming skills. If not I recommend finding someone with good programming skills to help you as it is pretty complicated.
July 2, 2014 at 11:10 am - Permalink
You load the whole file using
This will create a wave named RawData.
Then write a loop that scans through RawData finding the start and number of points in each section.
For each section you read the experiment number, pattern number and repeat number, and determine the starting data line and ending data line. You create a string variable containing the desired wave name and then use the information you have collected in a Duplicate/R command to create the data wave for that section. You then continue with the next section.
July 2, 2014 at 11:11 am - Permalink
July 13, 2014 at 04:43 am - Permalink