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
 single XY into multiple when importing 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
dkimia1001 Posted - 08/01/2016 : 12:04:12 PM
Origin Ver. and Service Release (Select Help-->About Origin): 2016 SR1
Operating System: Windows 7 64 bit

I have a CSV file containing long two columns of X & Y, which are a series of multiple measurements. Between each measurements, headers are inserted so it is easy for me to see which one is which in the file.

I tried importing and automatically adding new columns by choosing "Start new column" under Non-numeric data in a numeric field. It does does the job, but gets rid of all headers, making it hard for me to differentiate different columns.

I know how to add the headers for the first set, but is there a way to keep headers when adding new columns?

For example, for the data below, how do I say in the second XY columns, it is for time sweep 2?

time sweep 1
Shear Stress Viscosity
[Pa] [mPa·s]
1 1.29E+07
1.0638 1.81E+07
1.1316 2.23E+07
1.2038 2.40E+07
1.2805 2.57E+07
1.3622 2.57E+07
1.449 2.57E+07

time sweep 2
Shear Stress Viscosity
[Pa] [mPa·s]
1 1.29E+07
1.0638 1.81E+07
1.1316 2.23E+07
1.2038 2.40E+07
1.2805 2.57E+07
1.3622 2.57E+07
1.449 2.57E+07
1   L A T E S T    R E P L I E S    (Newest First)
Hideo Fujii Posted - 08/01/2016 : 5:30:04 PM
Hi dkimia1001,

You can set up how you handle the file header, thus you can deal with the sweep 1 header, but the rows
in the sweep 2 are not file header, but already a part of the data; So, you won't be able to deal with
the second group at the import time, I think - you need a post processing. (The typical situation may be
that groups are stored in multiple files, then luckily all would go smoothly by multiple file import.)

Now, if you import the CSV file you get all headers may be stored in the first column. Then, for example,
you inserted a column, and running the following formula, you can set the group number there:
i==1?1:(left(col(2)[i]$,4)$=="time"?col(1)[i-1]+1:col(1)[i-1])
Please see the sample below:



Then, you can unstack the worksheet using this group column. ("Worksheet: Unstack" menu)

The header information in the first 3 rows can be moved by the following script, for example:
/////////////////////////////////////////////
for(ii=1; ii<wks.ncols; ii=ii+2) { 
  wcol(ii)[L]$=token(wcol(ii)[1]$,1,' ')$;  //Time as Long Name1
  wcol(ii+1)[L]$=token(wcol(ii)[1]$,2,' ')$+" "+token(wcol(ii)[1]$,3,' ')$;  //Sweep# as Long Name2
  wcol(ii)[U]$=token(wcol(ii)[3]$,1,' ')$;  //Unit1
  wcol(ii+1)[U]$=token(wcol(ii)[3]$,2,' ')$;  //Unit2
  wcol(ii)[C]$  ="Shear Stress";
  wcol(ii+1)[C]$="Viscosity";
}
//wks.colsel(1,1);  //Select col(1)
//mark -d %C -b 1 -e 3;  //delete rows 1..3
//wks.colsel(1,0);  //Unselect col(1)
/////////////////////////////////////////////
(Sorry for cheating by putting literals in the process for the column labels.)

See the result below:



I hope this sample procedure is helpful.

--Hideo Fujii
OriginLab

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