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
 LabTalk Forum
 Book moves to another folder by itself

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
Clairekun Posted - 06/22/2022 : 1:07:26 PM
Origin Ver. and Service Release (Select Help-->About Origin): 2018b
Operating System: Win10

Hello,

I am running the code below to import files from 2 different folders, to their corresponding folder in my project explorer. The different datasets are imported to new worksheets.

StringArray OxAt = {"Atomic","Oxides"};
loop(i,1,OxAt.GetSize()) //For each of those strings
{
	string SEMFol$ = OxAt.GetAt(i)$; //Get the string name into a new string
	pe_cd path:="/_Data/%(SEMFol$)";
	string strPath$ = %XSEM\Unsorted EDX\%(SEMFol$);
	path$ = strPath$;
	findfiles;
	impasc 
	Options.FirstMode:=3	//Import first dataset to a new sheet 
	Options.Mode:=4 	//Import 2nd to nth workbook to new sheets       
	Options.Sparklines:=2 	//Sparklines if there are less than 50 columns.
	Options.Headers.CountHeaderLines:=1	//Confirm there are headers in the source data sets
	Options.Headers.MainHeaderLines:=0	//Specify number of headers
	Options.Headers.SubHeaderLines:=1	//Specify number of subheaders
	Options.Headers.LongName:=1	//Set 1st subheader as long name
	Options.Names.AutoNames:=0	//Do not rename workbooks automatically
	Options.Names.FNameToColComm:=0	//Use file names in column comments  
	Options.Names.FNameToSht:=1	//Use file names to rename worksheets
	Options.Names.FNameToBk:=0 //Do not fill comments with file names 
	Options.Names.FPathToComm:=0	//Do not fill comments with file path
	Options.FileStruct.NumSep:=1	//Decimals are after a dot (90.25). For 90,25 write 1 instead
	Options.FileStruct.Delimiter:=3;
	
	doc -ef LW 
	{
		//(irrelevant column values information)
	}

	newbook;
}

As you can see, the datasets are imported to /_Data/Atomic/ and /_Data/Oxides/ folders within the project explorer.

The import goes ok right until after doc -ef LW command. If I stop it there, I have one multi-worksheet book under each folder.

As soon as I include newbook command and run the code, both workbooks are placed under Atomic folder and one new, empty workbook is created under Oxides folder.

I simply cannot understand this behaviour. Please enlighten me.
2   L A T E S T    R E P L I E S    (Newest First)
Clairekun Posted - 06/22/2022 : 5:32:17 PM
That worked! Moving newbook right after pe_cd, and changing the first import mode to 0, did the trick.

Thanks for your help, I have been racking my brains for hours to try to figure out what was wrong in the code and, for once, it wasn't my fault lol.
YimingChen Posted - 06/22/2022 : 2:45:04 PM
This could be a bug. It occurs if there is no workbook in the current folder when importing. Can you instead move newbook; to the start of the loop?

James

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