Append to a compressed file

I have some test results that I want to save into a test result file. Since I will be accumulating many test results, I want to keep overhead down, so I would like to simply append the result to the end of the file. Here is what I have done...
1) Create an empty array, flatten to XML and write to a file.
2) When I want to add a record, I take the record control, flatten to XML, and then overwrite the </Array> at the end of the file with the XML record. I then append another </Array> onto the end of that to properly close it out.
3) I can then read this XML file back into an array of test record structures at a later time.
I chose to do it this way, because when I am generating the test records, I do not want the overhead of "file read->XML Parse entire file->append code->XML export appended structure->File write". I figured that by simply appending the XML record to the end of the file, I could cut down on a lot of this IO overhead.
The problem is that XML is a bit "chatty". I'd like to be able to read, write and append to compressed files (since XML compresses very well). The lvzlib routines only have a read and a write, but no append. My understanding of the compression schemes is that it makes a table of the common byte patterns and replaces them with shorter tokens. If I compress each record, I will have a table of tokens for each record that will basically be the same as all the other records. I can get better compression if I use one table for all records.
Has anybody implemented this, or do I need to dig into the guts of zlib?
Alternatively, can the normal File I/O routines be configured to work on a file in a compressed archive (like a zip file) and let the OS handle all the compression?
Thanks,
Brian Rose

Mister Rose wrote:
I have some test results that I want to save into a test result file. Since I will be accumulating many test results, I want to keep overhead down, so I would like to simply append the result to the end of the file. Here is what I have done...
1) Create an empty array, flatten to XML and write to a file.
2) When I want to add a record, I take the record control, flatten to XML, and then overwrite the </Array> at the end of the file with the XML record. I then append another </Array> onto the end of that to properly close it out.
3) I can then read this XML file back into an array of test record structures at a later time.
I chose to do it this way, because when I am generating the test records, I do not want the overhead of "file read->XML Parse entire file->append code->XML export appended structure->File write". I figured that by simply appending the XML record to the end of the file, I could cut down on a lot of this IO overhead.
The problem is that XML is a bit "chatty". I'd like to be able to read, write and append to compressed files (since XML compresses very well). The lvzlib routines only have a read and a write, but no append. My understanding of the compression schemes is that it makes a table of the common byte patterns and replaces them with shorter tokens. If I compress each record, I will have a table of tokens for each record that will basically be the same as all the other records. I can get better compression if I use one table for all records.
Has anybody implemented this, or do I need to dig into the guts of zlib?
Alternatively, can the normal File I/O routines be configured to work on a file in a compressed archive (like a zip file) and let the OS handle all the compression?
Thanks,
I'm not sure what you mean by appending. If you mean appending new data to an existing file in a ZIP archive this can't be done in any way. The ZIP file is not structured in a way that would allow appending data to an internal file stream inside the archive. I'm not even sure there is any compression scheme that would allow that. The only way for all standard compression schemes for this is to extract the file append the new data and then replace the existing file in the archive with the new one.
If you mean appending a new file to an existing archive then the newest released version 2.3 of lvzlib can do it. The ZLIB Open Zip Archive.vi function has an append mode input. Previously this was a boolean that indicated if a new file was to be created or if the archive should be tacked to the end of an existing file. In the new version this is an enum with an additional entry (adding to existing archive).
Rolf Kalbermatter
Message Edited by rolfk on 10-04-2007 09:21 AM
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions

Similar Messages

  • Problem in Compresses file.Not able to see the data in file

    Hi All,
    I am downloading file into application server.
    Using:
    OPEN DATASET file FOR OUTPUT FILTER 'compress'.
    OR
    DATA: l_command(100) type c.
       CONCATENATE 'compress ' p_file INTO lw_command SEPARATED BY space.
        ENDIF.
        CALL 'SYSTEM' ID 'COMMAND' FIELD lw_command.
    When I see the file content it contains junk characters.
    If I want to see the data Do I need to uncompress the file.
    con't we see the data without uncompressing the file?.
    Regards,
    vinod

    Hi,
    Uncompress is required to read the content of an Compressed file.
    OPEN DATASET DSN FOR OUTPUT FILTER 'compress'.
    OPEN DATASET DSN FOR INPUT FILTER 'uncompress'.
    The first OPEN statement opens the file so that the displayed data can be read into it in compressed form.
    The second OPEN statement opens the file so that the data is decompressed when it is read from the file.
    http://www.sapnet.ru/abap_docu/ABAPOPEN_DATASET.htm#&ABAP_ADDITION_8@14@

  • Problems with compressing  files with right hand click. it does not work.

    Problems with compressing files with right hand click.
    I am using the compress function in the Mac OS (File > Compress XX) from time to time. Today it does not work anymore. OS 10.5.6
    I get a message: The content list cannot be created for compressing.
    I tried it with files and folders and keep getting this message. Anybody any idea as to how to fix this

    Thanks I love my macbook!!!!
    I also got further problems such as copy-paste not working etc.
    so I fixed it just this morning by running Applejack 1.5 and am back up running noticing your post.
    thanks for helping though!

  • Reading a Compressed File from a ZIP File, which is an entry of ZIP File

    Hello, Experts,
    Would it be possible somebody to help me with code example for the following problem?
    I want to read a compressed file from a ZIP file, which is an entry of ZIP File, without extacting/writing files on file system. Is this possible?
    Lets say we have a ZipFile1. There is ZipFile2 inside ZipFile1. And inside ZipFile2 is FileA. The scenario is reading FileA without extracting on file system.
    Thank you in advance for your help.
    Cheers
    RADY

    The classes you want to be using are java.util.zip.ZipInputStream and and ZipEntry from the same package. Construct the ZipInputStream with the input you have for the outer zip. Loop with ZipInputStream.getNextEntry until you find the inner zip you're looking for - that method returns a ZipEntry, and you get the name of the zip entry with ZipEntry.getName. Read the ZipInputStream from that point into some buffer, and read that buffer into a new ZipInputStream - rinse and repeat until you have the contents of the file in the zip in the zip...

  • How to append records in a file, through file adapter.

    Hi All,
    How to append records in a file, through file adapter.
    I have to read data from database and need to append all records in a file.
    Thanks in Advance.

    Hi,
    I think you have a while loop to hit the DB in your Process (As you said you have to fetch data from DB 10 times if 1000 rec are there)
    First sopy your DB O/P to one var
    and from second time append to previous data.(Otherwise you can directly use append from starting instead of copy and append)
    When loop completes you can transform to File adapter Var.
    Otherwise you can configure yourFileadapter such that it will aapend current records to previous records.
    You can use 'Append= true' in your file adapter wsdl.
    It will append previous records to current records in the same file.
    Regards
    PavanKumar.M

  • Append data into the file in application server

    Hi Friends,
    I have an issue where i have a job which has three different stepst for same program. If i run the job the program will create a file in the application server and append the other two steps in the same file without overwriting the file or creating a new file.
    My problem is like its creating three different files in application server for that particular job since it has three steps . Its not appending into one particular file .
    I am using the FM 'Z_INTERFACE_FILE_WRITE' where i have used the pi_append in the exportng parameter . ITs working when i specify the file in local system. It is appending correctly when i run the report normally to apppend into local system.
    But when i schedule a job to append the file in application server its creating three different files.
    Kindly help me if anyone is aware of this issue
    Thanks in advance
    Kishore

    Hi,
    Please use open dataset to write and append files.Please check the logic of Z FM which you are using .
    To open and write into a file  use
    OPEN DATASET FNAME FOR OUTPUT.
    To append data into existing file use
    OPEN DATASET FNAME FOR APPENDING.
    To write into file:
    v_file = file path on application server
      OPEN DATASET v_file FOR output.
      IF sy-subrc NE 0.
    write:/ 'error opening file'.
      ELSE.
       TRANSFER data TO v_file.
      ENDIF.
    CLOSE DATASET v_file.
    For appending :
    OPEN DATASET v_file fOR APPENDING.(file is opened for appending data  position is set to the end of the file).
    Thanks and Regards,
    P.Bharadwaj

  • Can Acrobat Standard append to an existing file when saving?  Can Pro?

    Hello all,
    I'm wondering if Adobe Acrobat Standard has the function to save to an existing file. I don't mean append two PDF's together after they are already created. I mean I already have a PDF document which I need to add lots of additional pages to. So when creating additional PDF's, I want to be able to tell Acrobat to add those files to the end of the document I already have.
    PrimoPDF has this feature which would be a real time-saver in my line of business. In that program, you simply choose the same filename when asked to save the document. It then prompts you to overwrite or append-to the existing file. For business reasons, it would be very advantageous to use Acrobat rather than Primo. Does anyone know if Acrobat Standard can do this? If not, does Pro do it? Thanks for your time. I appreciate any feedback I get.
    Chris

    Never tried that... you might read in the Acrobat Pro User Guide Online
    http://www.adobe.com/support/documentation/en/acrobatpro/

  • How to search for file within compressed file

    I hope i can explain this correctly, I apologize in advance.
    What is the command to search for a file that may/may not exist within another compressed file?
    Situation is that I have a cron job that compresses the files in a folder on a scheduled date. I now need to search for a file that may exists in one of the several compressed files, which was a result of the cron job.
    Thanks in advance

    There's an open source utility called zgrep. You can probably get it from http://www.sunfreeware.com/ .
    HTH,
    Roger S.

  • Export to disk compressed files only? bad bad bad

    When I select the export to disk under the share menu, it will only export compressed files. This is a drag because the only way to export an aiff is if you send it to itunes. Am I wrong about this, is there something that I am missing?
    Exporting to disk allows you to select a destination for the export and this is highly desirable because I don't like cluttering up my itunes library with snippets of songs or individual tracks.
    If this is the case than GB 3 has a serious design flaw. Export to disk is a basic function of all music software. To hobble this on purpose is beyond my understanding.
    Anyone out there know the answer?

    Garageband 1 and 2 have the same flaw. 8^) Exporting to iTunes is the "official" Apple way. I would create a special playlist for your GB exports so you can keep track of them and delete them as necessary.

  • Appending objects in text file and searching.......

    I have been trieng to implement simple search operation on the class objects stored in the text file. but when i try to append new objects in the same file and search for the same; java.io.StreamCorruptedException is thrown. wat the problem is, that wen i append to the text file; it stores some header information before the actual object is stored and on the deserialization, this header information is causing the exception. the same header information is stored every time, i append to the file. anybody knws hw to get past it??? my code is as given below:
    package coding;
    import java.io.BufferedReader;
    import java.io.EOFException;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.ObjectInputStream;
    import java.io.ObjectOutputStream;
    import java.io.PrintWriter;
    import java.io.Serializable;
         class Employee implements Serializable{
              private static final long serialVersionUID = 1L;
              String name;
              int id;
              public int getId() {
                   return id;
              public void setId(int id) {
                   this.id = id;
              public String getName() {
                   return name;
              public void setName(String name) {
                   this.name = name;
              public Employee(String name, int id) {
                   this.name = name;
                   this.id = id;
         public class FileSearch{
         public static void main(String[] args) throws IOException
              /*Entering the records into the file*/
              Employee ob = null;
              File file=new File("c:\\abc.txt");
              InputStreamReader isr=new InputStreamReader(System.in);
              BufferedReader stdin=new BufferedReader(isr);
              char fileExist='y';
              if(file.exists())
                   System.out.println("File already exists!!!");
                   System.out.println("Append New Records(press y) Or Search Existing File(press any other button)?:");
                   String strTemp=stdin.readLine();
                   fileExist=strTemp.charAt(0);
              else
                   System.out.println("File doesnt exist; creating new file......");
              if(fileExist=='y')
                   FileOutputStream fos=new FileOutputStream(file,true);
                   ObjectOutputStream oos=new ObjectOutputStream(fos);
                   char choice='y';
                   System.out.println("Enter records:");
                   while(choice=='y')
                        System.out.println("enter id:");
                        String id_s=stdin.readLine();
                        int id=Integer.parseInt(id_s);
                        System.out.println("enter name:");
                        String name=stdin.readLine();
                        ob=new Employee(name,id);
                        try
                             oos.writeObject(ob);
                             //count++;
                             oos.flush();
                        catch(Exception e)
                             e.printStackTrace();
                        System.out.println("Enter more records?(y/n)");
                        String str1=stdin.readLine();
                        choice=str1.charAt(0);
                   oos.close();
              /*Searching for the record*/
              System.out.println("Enter Record id to be searched:");
              String idSearchStr=stdin.readLine();
              int idSearch=Integer.parseInt(idSearchStr);
              try
                   FileInputStream fis=new FileInputStream(
                             file);
                   ObjectInputStream ois=new ObjectInputStream(fis);
                   int flag=1;
                   FileReader fr=new FileReader(file);
                   int c=fr.read();
                   for(int i=0;i<c;i++)
                        Object ff=ois.readObject();
                        Employee filesearch=(Employee)ff;
                        if(filesearch.id==idSearch)
                             flag=0;
                             break;
                   ois.close();
                   if(flag==1)
                        System.out.println("Search Unsuccessful");
                   else
                        System.out.println("Search Successful");
              catch(Exception e)
                   e.printStackTrace();
    }

    966676 wrote:
    All what I need to elect by who this word repeated. But I don't know really how to make It, maybe LinkedListYou should choose the simplest type fullfilling your needs. In this case I'd go for <tt>HashSet</tt> or <tt>ArrayList</tt>.
    or I dont know, someone could help me?You need to introduce a variable to store the actual name which must be resetted if an empty line is found and then gets assigned the verry next word in the file.
    bye
    TPD

  • File Share Search problem with Compress file

    I have a content source in SharePoint 2013 search which crawl files from a file share. Some of the files have "Compress contents to save disk" attribute set to true. 
    These files are being crawled as I can see them in Crawl logs. But when I search for these documents in search center, it only return the documents which don't have compression attribute set.  I have even tried searching document title. Any idea?

    Hi Rashid,
    What keyword did you use for searching the compressed file?
    As your description, I set a file as the below:
    Then I created a File Share content source pointed to the folder which contains the file, then start a full crawl.
    After crawling, I went to my search center, and searched, the result was:
    When you search the compressed file, check whether the item title returns a part of the content of the document.
    Best Regards,
    Wendy
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Wendy Li
    TechNet Community Support

  • How to append Objects in a file.

    i have the following sample code ,
    its not read data properly and throws Stream Corrupted Exception in the appended record. ( at Last statement of try block ).
    Thanks,
    import java.io.*;
    public class IOError {
    public static void main(String[] args) {
    try {
    ObjectOutputStream oos = new ObjectOutputStream(
    new FileOutputStream("data.dat"));
    oos.writeObject(new String("string 1"));
    oos.writeObject(new String("string 2"));
    oos.flush();
    oos.close();
    ObjectInputStream ois = new ObjectInputStream(new FileInputStream("data.dat"));
    System.out.println("----- Round 1 Starts ---------");
    System.out.println((String) ois.readObject());
    System.out.println((String) ois.readObject());
    ois.close();
    ObjectOutputStream oos2 = new ObjectOutputStream(
    new FileOutputStream("data.dat",true)); // Appending Data
    oos2.writeObject(new String("string 3"));
    oos2.flush();
    oos2.close();
    ObjectInputStream ois2 = new ObjectInputStream(new FileInputStream("data.dat"));
    System.out.println("----- Round 2 Starts ---------");
    System.out.println((String) ois2.readObject());
    System.out.println((String) ois2.readObject());
    System.out.println((String) ois2.readObject()); // Stream Corrupted Exception
    catch(Exception e) {
    System.out.println(e);

    Nasty. When you open an ObjectOutputStream, it will write a few initializing bytes, so if you really want to append objects to a file, then after you read the first two strings, you need to create a new ObjectInputStream that will read those bytes.
    You could write an object indicating that now you are done with this ObjectOutputStream, so when you read the file and read this object, you know you have to create a new ObjectInputStream.
    oos.writeObject(new String("string 1"));
    oos.writeObject(new String("string 2"));
    oos.writeObject(null); // null could be used if you know you won't write any other null's in your code.
    //... append
    oos.writeObject(new String("string 3"));
    oos.writeObject(null);
    // read:
    FileInputStream fis = new FileInputStream("data.dat");
    ObjectInputStream ois2 = new ObjectInputStream(fis);
    String s;
    while ((s = (String)ois2.readObject()) != null) {
      System.out.println(s);
    ois2 = new ObjectInputStream(fis);
    while ((s = (String)ois2.readObject()) != null) {
      System.out.println(s);

  • Append functionality in Outbound File Adapter

    Hi all,
    I have a question regarding append functionality in outbound file adapter.
    When I append files for example I get a XML file with different XML files in one file, but is it also possible to collect and bundle the files and get a same result when u use BPM?
    Do I have to add some parameters?
    Kind regards,
    Kamran Vakili

    It is not possible, when you append XML files.
    The result XML file is not valid, as you have multiple declarations and root tags.
    The append mode for the file adapter should be used only for flat files.
    Regards
    Stefan

  • How to not append '.PART' to the file name of the currently downloading file, and just download the file with its normal filename

    In Windows, when Firefox (I'm currently using 7.0) downloads a file, it appends ''.PART'' to the file name of the currently downloading file and just renames it to its original file name after it finishes downloading.
    I sometimes like to watch a currently downloading video file, so it will be better if Firefox just downloads the file to its actual filename (like what Opera does), so I can easily double click the incompletely downloaded file and watch it with the video player assigned to that file extension, rather than the awkward ''Right click -> Open With -> Choose Default Program'' route with .part files.
    Does anyone know how to set Firefox to do this?

    It is possible that your anti-virus software is corrupting the downloaded files or otherwise interfering with downloading files by Firefox and prevents Firefox from renaming the .part file.
    Try to disable the real-time (live) scanning of files in your anti-virus software temporarily to see if that makes downloading work.
    See "Disable virus scanning in Firefox preferences - Windows"
    * http://kb.mozillazine.org/Unable_to_save_or_download_files

  • Permission denied - unable to "compress" file

    Hi I have a weird scenario which I would need help on.
    SunOS mysvr 5.10 Generic_127127-11 sun4u sparc SUNW,Sun-Fire-880
    I have a user "myuat" which belongs to a group "pc"
    # id
    uid=30008(myuat) gid=101(pc)
    and in /etc/group
    pc::101:otheruat,myuat
    I am running a compress command to compress a file in a directory and I get permission denied
    # cd /myprod/mycor/mycom/myarch
    # compress mytxtcom.20080804
    mytxtcom.20080804: Permission denied
    # ls -l mytxtcom.20080804
    ----rwx---+ 1 myuat pc 239268 Aug 5 00:23 mytxtcom.20080804*
    # getfacl mytxtcom.20080804
    # file: mytxtcom.20080804
    # owner: myuat
    # group: pc
    user::---
    group::rwx #effective:rwx
    group:hmis:r-- #effective:r--
    mask:rwx
    other:---
    # getfacl /myprod/mycor/mycom/myarch
    # file: /myprod/mycor/mycom/myarch
    # owner: root
    # group: pc
    user::---
    group::rwx #effective:rwx
    group:hmis:r-x #effective:r-x
    mask:rwx
    other:---
    I noticed that if I chown from:
    ----rwx---+ 1 myuat pc 239268 Aug 5 00:23 mytxtcom.20080804*
    TO:
    ----rwx---+ 1 root pc 239268 Aug 5 00:23 mytxtcom.20080804*
    then I will be able to compress the file, why? I wonder why "myuat" id is not able to compress file eventhough it belongs to same group?
    ----rwx---+ 1 myuat pc 42120 Aug 5 00:23 mytxtcom.20080804.Z*
    Any idea? Please help.
    Thanks

    Were you the root user when you compressed the file?
    It looks like the user 'myuat' does not have permission to write to the '/myprod/mycor/mycom/myarch' directory. You need to have write permission to the directory in order to compress a file in it, even if you have permission to write to the file itself.

Maybe you are looking for

  • Notifications of updates, but no updates in app store

    I'm getting notifications that updates for Mountain Lion are available, but then when I go to the app store and check for updates nothing shows up. I've checked all the usual update and Apple account settings and can't see anything out of the ordinar

  • View all open applications: workaround?

    It used to be I could hit a hotkey or a hot corner and see windows for all open applications and jump from one to the other.  It seems that's no longer possible.  Is there a workaround???

  • Reg:User Exit For Invoice

    Hi All, I have an requirement that when during creation of invoice i have to update some data's to ztables and during deletion of invoice i have to update some data's. Is it possible? Is there any user exit for this scenario? Kindly give your idea's

  • Itunes uses lots of memory in Vista

    Hey, I don't know if any of you out there have the same problem with itunes and vista but when I run itunes it uses 300MB to 1.2GB of RAM at any given time. I am confused why Itunes would take soo much memory just to play songs. If anyone knows how t

  • How to install Essbase 9

    Hi All This is a new comer for Essbase, today encounter an urgent issue for setup Essbase 9.3.1 on Linux platform. I installed that but can't start Administration Services console , thereby I can not to create database and operate. I have installed A