Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks, I am parsing a couple of excel sheets which are arount 6MB capacity. The problem is that if i parse all these files (say 10 such files) then after extracting data from all the files the program does not exit even if it at the end of the program, it just hangs in there. When i see what exactly is happening using the unix top command then i see that this process is using almost 85 to 90% memory and is varying even after the program is ended (cpu usage = 1-2%). Can any body what exactly is happening and a solution to it. But if i parse them individually then there is no problem it uses limited memory and then the program exits early. I have one more query is there a way to split a single excel file into multiple ones using some perl module or some thing. Because i need to parse a file which is filled row wise and about 44 columns are filled. Hence i need to break this into two and then parse individually. Or can somebody suggest a way to convert a excel file into CSV(comma seperated values) format.

Replies are listed 'Best First'.
Re: Problem parsing the excel sheet
by jmcnamara (Monsignor) on Feb 28, 2005 at 11:40 UTC

    When i see what exactly is happening using the unix top command then i see that this process is using almost 85 to 90% memory and is varying even after the program is ended
    Spreadsheet::ParseExcel is known to consume large amounts of memory for megabyte sized Excel files. See also Reducing the memory usage of Spreadsheet::ParseExcel.

    But if i parse them individually then there is no problem
    If your program can handle the files individually but not together then I'd guess that you are creating a new Spreadsheet::ParseExcel object for each file which, given the standard memory usage, is inefficient. If this is the case then try reuse the same object reference for each new file.
    I have one more query is there a way to split a single excel file into multiple ones using some perl module or some thing.
    Apart from Spreadsheet::ParseExcel the other main way would be to use Win32::OLE on Windows (or possibly on Linux).
    Or can somebody suggest a way to convert a excel file into CSV(comma seperated values) format.

    The OS spreadsheet application Gnumeric contains a command line utility that allows you to convert spreadsheets from one format to another:

    $ ssconvert simple.xls simple.csv

    --
    John.

Re: Problem parsing the excel sheet
by hawtin (Prior) on Feb 28, 2005 at 10:19 UTC

    There are a number of ways to really mess up the memory handling. I suggest you summarise the key parts of your perl code, without seeing that it is hard to suggest what is wrong.

    (One thing that I found recently was the use of the ".=" operator)

Re: Problem parsing the excel sheet
by holli (Abbot) on Feb 28, 2005 at 10:10 UTC