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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Book moves to another folder by itself
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Clairekun

Germany
175 Posts

Posted - 06/22/2022 :  1:07:26 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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.

YimingChen

1593 Posts

Posted - 06/22/2022 :  2:45:04 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

Clairekun

Germany
175 Posts

Posted - 06/22/2022 :  5:32:17 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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.
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000