The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 import ASCII -> create wks

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
prgo Posted - 12/01/2006 : 09:17:30 AM
Origin Version (Select Help-->About Origin): 7.0
Operating System:WinXP

this is a problem (at least for me):
i want to import a few "n" ASCII files,
and to put them in "n" wks,
with names "data/i" where i goes from 1 to n.

because, for the rest of the function i need that "n" as a number,
and wks-s names!

is it possible to make some loop to recognize the number of imported files, and generate the names?

prgo
4   L A T E S T    R E P L I E S    (Newest First)
prgo Posted - 12/02/2006 : 5:57:04 PM
thanks,thanks!!!!
zachary_origin Posted - 12/01/2006 : 12:23:25 PM

void testWks()
{

string strDataWks;
Worksheet wksCorr("correction");

Worksheet wksRes;
wksRes.Create();
wksRes.GetPage().Rename("Results");
while(wksRes.Columns.Count()<7)wksRes.AddCol();

Dataset dsColA(wksCorr,0);
Dataset dsColB(wksCorr,1);
Dataset dsColAA(wksRes,0);

dsColAA=dsColA;

for (int ii=2; ii<=6; ii++)
{
strDataWks.Format("data%d",ii);
Worksheet wks(strDataWks);
Dataset dsColF(wks, 5);
Dataset dsColBi(wks,ii-1);
dsColBi = dsColF*dsColB;
}

}


Zachary
OriginLab Technical Services.
prgo Posted - 12/01/2006 : 11:33:53 AM
File>Import>ASCII Options...
with that i get dataset with the name of the original file name
i would like to make it more general, so when i import for example 5 different datasets, then my script should recognize that i have 5 different wks, and give them generic names from data1 to data5.

here is my very rough idea what should be in that script,
all these names i have to put "by hand" in OPJ...

void test ()

{

Worksheet wks1("correction");
Worksheet wks2("data1");
Worksheet wks3("data2");
Worksheet wks4("data3");
Worksheet wks5("data4");
Worksheet wks6("data5");

Worksheet wks7;
wks7.Create();
wks7.GetPage().Rename("Results");

Dataset dsColA(wks1,0);
Dataset dsColB(wks1,1);
Dataset dsColF(wks2,5);
Dataset dsColFF(wks3,5);
Dataset dsColFFF(wks4,5);
Dataset dsColFFFF(wks5,5);
Dataset dsColFFFFF(wks6,5);
Dataset dsColAA(wks7,0);
Dataset dsColBB(wks7,1);
if (wks7.Columns.Count()==2)wks7.AddCol();
Dataset dsColBC(wks7,2);
if (wks7.Columns.Count()==3)wks7.AddCol();
Dataset dsColBD(wks7,3);
if (wks7.Columns.Count()==4)wks7.AddCol();
Dataset dsColBE(wks7,4);
if (wks7.Columns.Count()==5)wks7.AddCol();
Dataset dsColBF(wks7,5);


dsColBB.SetSize(dsColF.GetSize());

dsColAA = dsColA;
dsColBB = dsColF * dsColB;
dsColBC = dsColFF * dsColB;
dsColBD = dsColFFF * dsColB;
dsColBE = dsColFFFF * dsColB;
dsColBF = dsColFFFFF * dsColB;


GraphPage gr;
string strTemplate = "template.otp";
BOOL bOK = gr.Create(strTemplate, CREATE_VISIBLE);

if (!bOK)
return;

GraphLayer grlay = gr.Layers(0);
ASSERT(grlay.IsValid());

int d = wks5.Columns.Count();
int ii = 1;

for (ii = 1; ii < d+1; ii++)
{
Curve cv(wks7,0,ii);

int nPlot = grlay.AddPlot(cv, IDM_PLOT_LINE);
if (nPlot >= 0)
grlay.DataPlots(nPlot).SetColor(ii, TRUE);
grlay.Rescale();

}

}


Mike Buess Posted - 12/01/2006 : 11:19:09 AM
Hi prgo,

Are you importing via File > Import > Multiple ASCII or a custom Origin C function? If the latter please show us what you have so far. Also, what are "wks-s names"?

Mike Buess
Origin WebRing Member

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000