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
 Adding headers to files after/before data import

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
liam3001 Posted - 11/08/2007 : 04:24:32 AM
Origin Version (Select Help-->About Origin): 7.5
Operating System: XP

Hello All,
I'm using Origin in conjunction with Labview to collect data from and experimental setup. I would like to add header data to the file before I add the data but even if I move the data to rows below the header it gets written over by the new data. I have not tried inserting the header data afterwards but expect I will get a similar problem.

Essence of problem is writing header to file before data and not deleting that header when adding data. The header and data import is all done in the same step.

Any insight greatly appreciated.

Liam.
7   L A T E S T    R E P L I E S    (Newest First)
Mike Buess Posted - 11/09/2007 : 12:40:44 PM
In Origin itself you add a text label to the active worksheet by executing the following commands from the script window. '\n' is new line and the '-p x y' option positions the label on the worksheet.

%Z="line 1\nline 2\nline 3"; // assign header lines to string variable %Z
label -s -sa -p 50 0 %Z; // create a text label with header string

Looking at the available Origin VIs it appears there are two options for creating the label in LabView...

1. For simple header you can skip the %Z variable and execute the following command with OAExecute.vi...

label -s -sa -p 50 0 "line 1\nline 2\nline 3";

2. For more complicated header you might want to define %Z with OASetLTStr.vi and then execute the original label command with OAExecute.vi.

Mike Buess
Origin WebRing Member
liam3001 Posted - 11/09/2007 : 10:21:03 AM
OK this would be fine, could you outline briefly how saving this text label works.

Ta
Liam.
Mike Buess Posted - 11/09/2007 : 08:45:31 AM
So this is really a LabView question? Sorry, but it's been several years since I programmed LabView so I probably can't help. That said, it looks like you are not saving a data file but rather an Origin project that contains a worksheet with the data. You can't add a header to an Origin project but you can save the information in a text label on the worksheet with OAExecute.vi.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 11/09/2007 09:21:23 AM
liam3001 Posted - 11/09/2007 : 04:19:09 AM
Hi again,
I think the easiest thing to do is look at the basic vi itself. You'll find the Origin communication vi's under the user library. If not then you can manually copy and paste the vi's from the origin installation from \origin\samples\automation\labview to the user vi file in the NI folder.

Look at utuorial 2. Easy setup where a 2D array of data is written to an origin file. What I'm interested in is adding 3 header lines to that data set before its transferred to the "save origin project" vi.

Hope this helps

Liam.
Mike Buess Posted - 11/08/2007 : 10:38:51 PM
quote:
Problem with this though it that the origin file is not .dat. The only input the OACommunication.vi in labview takes is an array and not a string which is what the headers are.
OK, perhaps I am confused now. The data file is binary and was created in LabView? You want to add an ASCII header and still be able to read the file in LabView and/or Origin? At the same time you're adding the header you want to import the data to Origin?

If the data are binary you must know the file structure and can use file::Read to read entire binary file to a vector or struct. It will be easier to read the final file if the header has a fixed size so you might want to create header, and also append the vector read from data file, with file::Write. (You can use file::SeekToEnd before appending data if necessary.) Rest is the same as above. How to import while you are doing all this depends on how you are importing... Import ASCII, Import Wizard or custom routine?

Without more details I'm not sure what else to suggest.

Mike Buess
Origin WebRing Member
liam3001 Posted - 11/08/2007 : 11:09:25 AM
Hello Mike,
Problem with this though it that the origin file is not .dat. The only input the OACommunication.vi in labview takes is an array and not a string which is what the headers are.

I hope Im explaining myself OK.

L.
Mike Buess Posted - 11/08/2007 : 08:33:52 AM
Hi Liam,

This is the how I would add a header to C:\Data.dat...

1. Write header one line at a time to a new file (C:\Temp.dat) using stdioFile::WriteString.
2. Read Data.dat one line at a time using stdioFile::ReadString and write to end of new file with WriteString.
3. Delete Data.dat with DeleteFile("C:\\Data.dat") and rename new file as Data.dat with RenameFile("C:\\Temp.dat","C:\\Data.dat").

Mike Buess
Origin WebRing Member

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