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
 Origin Forum
 Import quoted numeric strings as numbers
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

hpdab

.
Posts

Posted - 01/24/2005 :  4:38:52 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I'm using Origin 7.5 to plot data collected with some legacy data acquisition software which saves the data as quoted strings with comma delimiters, for example, a record of the log time and some temperatures might look like

"0.1667","123","345","456"

I've looked over the Import wizard settings & cannot figure out how to convince Origin to import the quoted strings as numbers. I can import in Excel first, then cut&paste into the Origin data window, but I would rather just import the file directly. I also tried searching the knowledge base with no luck.

Thanks for any help or suggestions.

Mike Buess

USA
3037 Posts

Posted - 01/25/2005 :  07:22:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The easiest solution to this old problem is to import as text and remove the "" later. I assume you know how to do the first part with the Import Wizard. The second part can also be accomplished with the Wizard as follows...

On the Wizard's Save Filters page check the Save Filter option and specify the location. Then check "Specify advanced filter options" at the bottom and click Next. Enter the following script in the LabTalk code section...

get col(1) -e nrows;
loop (i,1,nrows) {
loop (j,1,wks.ncols) {
%A=cell(i,j)$;
cell(i,j)$=%A;
};
};

This method is not particularly fast since it strips the "" one cell at a time. But it's much better than going through Excel.

...The following Origin C method is much faster.
void remove_all_quotes()
{
Worksheet wks = Project.ActiveLayer();
Dataset dd;
StringArray sa;
string str;
foreach (Column cc in wks.Columns)
{
dd.Attach(cc);
dd.GetStringArray(sa);
str.SetTokens(sa,'|');
str.Remove('"');
str.GetTokens(sa,'|');
dd.PutStringArray(sa);
}
}


After you've compiled the function just replace the LabTalk script at the top of this message with the single command

remove_all_quotes;

Note that all columns must be text+numeric in order for this to work.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 01/25/2005 4:58:08 PM
Go to Top of Page

nilaysoft

China
Posts

Posted - 01/25/2005 :  9:45:08 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I have created an OPK add-on for you by combining Mike's subroutine. With this add-on, you can import you legacy data very conveniently.

Steps:
1. Download: File Exchange > Category:Import > Import quoted numeric strings as numbers

2. Drag the downloaded "import_quoted.opk" and drop it onto OriginPro window.

3. A new toolbar button is created. Clike this button and select one or multiple files to import.

4. Done.
Go to Top of Page

eparent

118 Posts

Posted - 01/26/2005 :  10:08:54 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
An option to remove quotes when importing data is planned for the Import Wizard in Origin version 8. This has been trackered and has Id #6355.


Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 01/26/2005 :  10:56:13 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Meanwhile, nilaysoft's add-on worked fine in my tests. Well done!

http://www.originlab.com/fileexchange/details.aspx?fid=92

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 01/26/2005 10:57:46 AM
Go to Top of Page

hpdab

.
Posts

Posted - 01/31/2005 :  10:15:24 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Mike, nilaysoft - thanks a lot! This is tremendous, and I really appreciate your help.
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