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
 Origin Forum
 How to remove quotes around imported data?

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
Jweale Posted - 02/29/2000 : 7:11:00 PM
I just know this has a simple answer but I haven't been able to track it down. I am importing data from an ascii file like the following:

"Channel Name","Date","Time","Value"
"TONS ","2/22/00","11:40:00", 37.12
"TONS ","2/22/00","11:41:00", 37.06
"TONS ","2/22/00","11:42:00", 33.94

When imported, I have 4 columns. The problem is that there are quotes around the data in the first three columns, so it is not a recognized date or time format. Is there an easy way to just remove all the quotes from the data? What script would work? I am using Origin 6.0. I tried to piece together a script (see below for the ugly mess), but am having no luck getting it to work. So, if it is a script solution, any hints on how to get data to and from a worksheet (whenever I try to set the value of a cell it ends up as -) and how to parse for the quote character, will looking for """ work?

Thank you for any assistance,

John Weale

/*
Will parse the selected range of cells to remove unwanted " characters
DOESN'T WORK -- all cells end up as -
*/

loop(jj,selc1,selc2) {
loop(ii,selr1,selr2) {

%O=col($(jj))[$(ii)];
loop(kk,1,%[%O]) {
if(%[%O,kk:kk]==""") %Z=%Z
else %Z=%Z%[%O,kk:kk];
}
col($(jj))[$(ii)]=%O;
};
};

6   L A T E S T    R E P L I E S    (Newest First)
rtoomey Posted - 03/23/2000 : 12:13:00 PM

I just remembered something...

A while back I actually entered a suggestion which would solve your problems. If implemented, the suggestion will provide for a chr() function which would essentially be the inverse of the asc() function.

I have added your name to the suggestion and increased the customer count by 1 in order to increase the suggestion's priority.

Since this function is not yet available, your only current option would be to create some sort of scheme based on the alphabet through script. Perhaps you could make use of a worksheet column which has each character of the alphabet entered into individual cells?

I hope that this information helps. If the suggestion is implemented we will contact you via e-mail when the appropriate release is available. If your e-mail address changes prior to that time I would encourage you to e-mail us with the change. Reference "Tracker item #5627" and provide us with your serial number if you do.

Sincerely,
Ryan Toomey


[This message has been edited by rtoomey (edited 03-23-2000).]

Jose Posted - 03/23/2000 : 8:44:00 PM
"...we do not provide a function such as you describe (Chr$) since most characters can be interpretted correctly by placing them in string variables"

Yes, but what if I want to auto-name worksheets, for instace, not with incremental numbers but characters? This is only an example in wich I need such a function, but more appear everyday. I would like to do something like


%n="Data1";

if(exist(%n)==2){
for(ii=61;ii>0;ii++) {
%z=%nCHR$(ii); // This line is wrong
if(exist(%z)==2) continue;
break; };
%n=%nCHR$(ii); } // This line is wrong


window -t wks origin %n; //Create %n

This would create "Data1a" if "Data1" already exists, and would increase in later executions as "Data1b" and "Data1c" and so on... if CHR$ function existed. (Based on Gary's code in a previous topic).

Any idea?

Jose.

[This message has been edited by Jose (edited 03-23-2000).]

Mike Buess Posted - 03/23/2000 : 8:38:00 PM
Jose,

Although somewhat inelegant, this script should do what you want. It'll need more work if you have to create more than 26 data sets.

%n="Data1";
if(exist(%n)==2) {
%m="abcdefghijklmnopqrstuvwxyz";
for(ii=1;ii<27;ii++) {
%z=%n%[%m,ii:ii];
if(exist(%z)==2) continue;
break;
};
%n=%Z;
};
window -t wks origin %n;

Mike

rtoomey Posted - 03/16/2000 : 2:03:00 PM

The script works for one double quote when "/" is replaced by one double quote. In other words, if you change the If statement to:

if(%[%p,kk:kk]==") {%Z=%Z;}

the script will work (even in the case you described where the quotes are in the middle of text).

I should also mention that we do not provide a function such as you describe (Chr$) since most (if not all other) characters can be interpretted correctly by placing them in string variables.

I hope this information proves helpful.

Sincerely,
Ryan Toomey

Jose Posted - 03/15/2000 : 8:02:00 PM
The following script solves the problem:


loop(jj,selc1,selc2) {
loop(ii,selr1,selr2) {

%o=col($(jj))[$(ii)];
%p=%o$;
col($(jj))[$(ii)]$=%p;
};
};

It's easy at the end, but hard to find... The re-assignment clears the quotes.

The correct working script for substituting certain character is as follows:


loop(jj,selc1,selc2) {
loop(ii,selr1,selr2) {

%z="";
%o=col($(jj))[$(ii)];
%p=%o$;

loop(kk,1,%[%p]) {
if(%[%p,kk:kk]=="/") {%Z=%Z;}
else {%Z=%Z%[%p,kk:kk];};

}

col($(jj))[$(ii)]$=%z;
};
};

In this case I delete the slash character "/".

This last code fails for double quote (") in the middle of the text (as in, for example, john"fastbullet"winston). You cannot simply use """ or """" to make it work. Is there any function like Chr$ to make this easier?

Jose.

Hideo Fujii Posted - 03/01/2000 : 12:29:00 PM
The following is not a sophisticated way, and I'm not sure whether you like or not, but try that...

When you import the data, set the import options [Delimited, Demilimter=Others "] (a double-quate). Also, in your case, [Skip Main header, Number of Lines=1]. Since you will see unnecessary columns for commas, delete those columns. Also, since you see the numerical column messed, change the column format from "Text&Numeric" to "Numeric". Now the column looks okay.

Does it help you?

--Hideo


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