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
 single XY into multiple when importing data
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

dkimia1001

S. Korea
Posts

Posted - 08/01/2016 :  12:04:12 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

Hideo Fujii

USA
1582 Posts

Posted - 08/01/2016 :  5:30:04 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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

Edited by - Hideo Fujii on 08/01/2016 5:42:54 PM
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