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 for Programming
 LabTalk Forum
 Adding text to worksheet export
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

cdrozdowski111

USA
247 Posts

Posted - 03/07/2013 :  12:41:28 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
OriginPro 9.0.0 SR1, Win7 64-bit, running in VMware Fusion 5.0.2

I need to export a 2 column worksheet as ASCII. I am aware of the expASC X-Function and am able to export my data properly. That's fine.

However, I need to add a number of text lines (with CRLF's) before the data AND one text line after the data in the file.

Can anyone suggest a way to do that?

cdrozdowski111

USA
247 Posts

Posted - 03/07/2013 :  10:04:57 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
To clarify, I have to import a data file with a specific format and perform operations on the data and export it back out in the same format.

Here is an example. The data is tab-delimited and the EOL characters are newlines (\n) not CRLF's as I said before.


OOIBase32 Version 1.0.0.8 Data File
++++++++++++++++++++++++++++++++++++
Date: Thursday, January 31, 2013, 11:03:33
User: Valued Ocean Optics Customer
Spectrometer Serial Number: 
Spectrometer Channel: Master
Integration Time (msec): 100
Spectra Averaged: 25
Boxcar Smoothing: 0
Correct for Electrical Dark: Disabled
Time Normalized: Disabled
Dual-beam Reference: Disabled
Reference Channel: Master
>>>>>Begin Spectral Data<<<<<
189.41	0.000
189.77	0.125
190.13	0.119
190.49	0.519
190.85	0.000
191.21	-0.824
191.57	0.000
191.93	0.632
192.29	-0.341

...

>>>>>End Spectral Data<<<<<

Go to Top of Page

greg

USA
1378 Posts

Posted - 03/08/2013 :  12:23:22 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You probably should be rolling your own read/write routines for custom files.

If you setup an import filter such that all those beginning rows go into worksheet parameter rows AND you do not remove that last line of text from your data then you can setup expasc to output almost an identical file as what was imported:

expasc iw:=<active> type:=dat path:="D:\direct.dat" longname:=0 units:=0 comment:=0 userparam:=1;

(I say almost, because the output file will be a few bytes longer due to extra tabs for empty parameter column values.)

But if you really want to delve into the area of "stupid Origin tricks", you can make use of the append feature expasc:

fname$ = "D:\Combined.dat";

// Export 'header'
newbook;
col(1)[1]$="Some stuff";
col(1)[2]$="++++++++++";
del col(2);
expasc iw:=<active> type:=dat path:=fname$;
win -cd %H;

// Export-append data
expasc iw:=<active> type:=dat path:=fname$ overwrite:=append;

// Export-append 'footer'
newbook;
col(1)[1]$="That's all folks.";
del col(2);
expasc iw:=<active> type:=dat path:=fname$ overwrite:=append;
win -cd %H;
Go to Top of Page

cdrozdowski111

USA
247 Posts

Posted - 03/08/2013 :  2:03:35 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
..."stupid Origin tricks"...


It's simply an unadvertised "power user" feature. Okay, duct tape and a screw driver but if it works... ain't no shame in that game!

I'll let you know what I come up with.
Go to Top of Page

greg

USA
1378 Posts

Posted - 03/20/2013 :  11:43:25 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
In the category of "You learn something new everyday" ..
Someone pointed out that there is a LabTalk option to the TYPE command that can create a file (if filename does not exist) or append to a file (if it does).

To start writing/appending to a file:
type -gb filename;
Subsequently, type commands go to default location and are echoed to the file.
To close the file:
type -ge;

// Example
type -gb "D:\My Log File.log";
ty $(@D,D10);
ty Saved %X%G.OPJ;
ty -ge;

This method is currently limited to DOS line ending mode (i.e. Carriage Return and Line Feed end the line.)

Edited by - greg on 03/20/2013 11:44:35 AM
Go to Top of Page

cdrozdowski111

USA
247 Posts

Posted - 03/20/2013 :  5:32:10 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks Greg!

Where that could be really useful (I solved my original issue), would be in the creation of log files for logging activities that occur in your scripts. For example, if you wrote a custom importation script of some type, you could log every file that was imported.
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