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
 Adding headers to files after/before data import
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

liam3001

Ireland
Posts

Posted - 11/08/2007 :  04:24:32 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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.

Mike Buess

USA
3037 Posts

Posted - 11/08/2007 :  08:33:52 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

liam3001

Ireland
Posts

Posted - 11/08/2007 :  11:09:25 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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.
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 11/08/2007 :  10:38:51 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

liam3001

Ireland
Posts

Posted - 11/09/2007 :  04:19:09 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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.
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 11/09/2007 :  08:45:31 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

liam3001

Ireland
Posts

Posted - 11/09/2007 :  10:21:03 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
OK this would be fine, could you outline briefly how saving this text label works.

Ta
Liam.
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 11/09/2007 :  12:40:44 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
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