Origin Version (Select Help-->About Origin): 7.5 Pro
Operating System: w2k
Dear forum,
I tried to use Origin C to make data import easier. I went through the tutorials and tried to understand the concept behind the language (programming is not new to me). The reason why I want to use Origin is the limited capacity of Excel in the amount of datasets. What I had in Excel was a tool that opens 255 files and reads datasets out of them. A standard case. In Origin, it doesn't seem that easy. Assuming the following format of data in one file:
...some rubbish
[Data]
0 7.8 3.3
0.5 4.6 4.5
...some more lines of data
That means three columns of which I always want one of them added to one created worksheet. A wish would be to dynamically recognize the amount of columns. What I tried so far:
/**************************************************************************************************/
// discard not needed lines until values of desired section
do
{
bRead = ffDataFile.ReadString(strHdr);
if(bRead && (strHdr.Match("[Data]")))
{
bRead = FALSE;
}
} while (bRead); // Create a worksheet; can I do this in a loop to create as many wks as there are columns?
Worksheet wksData1;
Worksheet wksData2;
bool bRetW = wksData1.Create();
bRetW = wksData2.Create(); //the first column is the time, so I just want to add it from the first ASCII-file
//but this does'nt work anyway (conditioned declaration, found no different way)...
if (intDataset==1)
{
Dataset ds1(wksData1,0);
Dataset ds2(wksData1,1);
Dataset ds3(wksData2,0);
Dataset ds4(wksData2,1);
}
else
{
Dataset ds1(wksData1,intDataset);
Dataset ds2(wksData2,intDataset);
} //now read data lines from the ASCII-file
do
{
bRead = ffDataFile.ReadString(strTmp);
if(bRead)
{
int ii = ds1.GetSize();
if (intDataset==1)
{
ds1.SetSize(ii+1);
ds3.SetSize(ii+1);
ds1[ii] = atof(strTmp.GetToken(0));
ds3[ii] = ds1[ii]; //time values are the same
ds2.SetSize(ii+1);
ds4.SetSize(ii+1);
ds2[ii] = atof(strTmp.GetToken(1));
ds4[ii] = atof(strTmp.GetToken(2));
}
else
{
ds1.SetSize(ii+1);
ds2.SetSize(ii+1);
ds1[ii] = atof(strTmp.GetToken(1));
ds2[ii] = atof(strTmp.GetToken(2));
}
}
} while (bRead);
/**************************************************************************************************/
This is just a kludge and not really good (it actually doesn't work->see comments). I wasn't able to find a way to solve that cleanly and with good programming techniques. Can you perhaps give me some code snippets for a good start?
Thanks in advance,
Armin
Edited by - ahuemm on 11/15/2005 1:47:22 PM
Edited by - ahuemm on 11/15/2005 1:50:37 PM