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
 compression
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Paul.Caste

Belgium
4 Posts

Posted - 12/09/2003 :  05:36:20 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
When importing ASCII data it would be nice to be able to read compressed ASCII data.
Is there a way to introduce such a filter to the ASCII import function?
I have written a DLL for importing the binary data we use here but for
ASCII data it would be nice to be able to keep all the options from the existing ASCII import function.


hajo_old

Germany
141 Posts

Posted - 12/09/2003 :  07:47:21 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello Paul

I yust want to make some suggestions ...

As you use compressed data files, I guess you have a dll or exe to compress or uncompress your ascii raw data.

By using the custom filter functionality you would have to create your own c code for handling the import. First uncompress, then read in the ascii file with a previous created custom filter definition file.

I don't know for shure, but it should be possible to call the ascii import filter wizzard (the wizzard dialog for defining the structure of the file) from OriginC (you will be able to call it as a labtalk menu command) so it should be easy to create a custom filter that first uncompresses the file and then calls the pure ascii for input into the wizzard ...

The following code shows a filter function I defined for my project:
(don't care about the REDIRECTION stuff ...)

int ImportSVTxtRangeDataFile(Page &pgTarget, TreeNode &trFilter, LPCSTR lpcszFile, int nFile)
{
// set redirection
int iRedirection = _REDIRECTION_OUTPUT_RESULTLOG("ImportSVTxtRangeDataFile ", true);
int iRet;

// check filter type
if( trFilter.Type.nVal != FILTER_TYPE_USERDEFINED )
return 1; // EXIT

// check existance of pgTarget
if( EXIST_WKS != pgTarget.GetType() )
return 1; // EXIT

Worksheet wks(pgTarget.GetName());
if( !wks.IsValid() )
return 1; // EXIT

// import data
// ----
// here would be one possibility to place the uncompressing code
// ----
// here my own import filter function is called,
// maybe it is more efficient to place the uncompressing code
// within the import-function ...
svTxtData data(lpcszFile); // this is a class I created to capsulate
// our txt data handling
iRet = data.importASCIIFilter(wks); // call the import member function

// Reset Redirection
_REDIRECTION_RESET(iRedirection);

return iRet;
}


Hope that helps a bit ...
Hajo

Feel free to ask for more details
...


-- --
Dipl.-Ing. Hans-Joerg Koch
Siemens VDO, Regensburg

SVDO_Origin1

Edited by - SVDO_Origin1 on 12/09/2003 07:49:43 AM
Go to Top of Page

Paul.Caste

Belgium
4 Posts

Posted - 12/09/2003 :  09:13:42 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Ho Hajo,

Thanks for the suggestion.
I am still using version 6, so no OriginC yet, but I will try to call the wizzard from within labtalk.
The ascii files are produced on a Unix machine, and are taking lots of diskspace. I would prefer to compress them there with gzip.

Best regards,

Paul Casteels

Go to Top of Page

hajo_old

Germany
141 Posts

Posted - 12/09/2003 :  09:53:55 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello, Paul

My code suggestion is based on Origin7.5(Pro).

For your purpose I would prefer to take the little money and upgrade to Origin 7.5Professional. The programming features for handling file import by yourself are worth it! Some more features are also really timesaving - like the new plot-dialog!

Maybe it would also be a good thing to write an extern dll (like you did for your bin-data) to handle the compression stuff by using MS-VisualC/C++ and then take LabTalk for reading in the Worksheets from the extracted ASCII files.

So far
Hajo

-- --
Dipl.-Ing. Hans-Joerg Koch
Siemens VDO, Regensburg

SVDO_Origin1
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 12/09/2003 :  11:53:42 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Paul,

Even with Origin 7.5 you'll need an external program to unzip your files before they can be imported. I'm pretty sure that WinZip will do it from GUI and if you have ample space on your Windows machine I'd suggest you unzip all of your files at once prior to importing. There are also free Windows versions of gzip that can do that from the command line. I don't remember which one I used a few years ago, but a Netscape search turned up this URL. A relatively simple LabTalk script based on the methods discussed in this Forum topic should work on a file-by-file basis in Origin 6. It would require a batch file similar to the following. Here I assume that if the data file is called filename then its compressed version is filename.z (I don't recall gunzip usage so the batch file will probably require some tweaking.)...

REM - Gunzip.bat (save to your Origin program folder)
@ECHO OFF
REM - go to compressed file folder
CD %1
ECHO [message] > gunzip.ini
ECHO Done=0 >> gunzip.ini
REM - call gunzip (fill in arguments)
"path to gzip\gunzip.exe" args %2
REM - notify Origin you're done
ECHO [message] > gunzip.ini
ECHO Done=1 >> gunzip.ini
CLS
EXIT
REM - End of Gunzip.bat

# LabTalk script
fdlog.dlgName$="Find compressed file";
fdlog.numTypes=1;
fdlog.type1$ = [Gzip (*.z)] *.z;
if(fdlog.open(A)==1) break 1;
%B=fdlog.path$; // path (%A=filename.z)
run -e Gunzip.bat "%B" "%A";
// wait for your gunzip to finish
ini.get.filename$=%Bgunzip.ini;
for(done=0;done<1;) {
done=ini.message.done;
};
%A=%[%A,'.']; // strip ".z" extension from file name
win -t D MyTemplate; // open new wks from your template (omit template name to use default)
open -w %B%A; // import unzipped file
# end of LabTalk script

Hope that helps.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 12/09/2003 11:58:35 AM
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