Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Install on demand ?

by Bod (Parson)
on May 07, 2024 at 12:36 UTC ( [id://11159320]=perlquestion: print w/replies, xml ) Need Help??

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

I am using Spreadsheet::Read to provide a universal way to read spreadsheets that users upload. I'm using this module because I have no idea what flavour of spreadsheet users might want to upload.

This module relies on others to do the work of reading the data. Is there a way to install the modules it uses "on demand"? So only when we first see a Lotus 1-2-3 spreadsheet, for example, do we install the module to read it.

The purpose of this is to convert the spreadsheet to CSV, so I have it in a standard format for the next part of the processing, which is mapping the data fields ready to import into a CRM - perhaps I am overthinking the universal spreadsheet part...

Replies are listed 'Best First'.
Re: Install on demand ?
by Corion (Patriarch) on May 07, 2024 at 13:15 UTC

    Personally, I would install everything relevant upfront just to be sure that the installation is in a known good state.

    An alternative could be to inform the user about the recommended modules using the recommends keyword in Module::CPANfile (if you use a cpanfile to install the prerequisites).

Re: Install on demand ?
by hippo (Bishop) on May 07, 2024 at 14:20 UTC
    The purpose of this is to convert the spreadsheet to CSV, so I have it in a standard format for the next part of the processing, which is mapping the data fields ready to import into a CRM - perhaps I am overthinking the universal spreadsheet part...

    This. I would allow the users to upload a CSV rather than some other format then the problem just goes away.


    🦛

      I would allow the users to upload a CSV rather than some other format then the problem just goes away

      We do allow users to upload a CSV file...
      However, our target market is charities - they are often run by people with restricted IT skills and saving an Excel file as CSV will be beyond some of them.

      But it probably makes sense to get this working with an uploaded CSV file then get the spreadsheet conversion working later.

        people with restricted IT skills and saving an Excel file as CSV will be beyond some of them

        From my experience, those people with low IT skills don't even know that Excel can save in different formats, and so each and every file that opens in Excel is called an Excel file - CSV, XLS, XLSX, XLSM, and so on. Completely logical from their perspective, and a big mess when you are in IT or application support. But that is also an advantage. All they know is Excel and MS Office, and they don't have the slightest idea that things like OpenOffice / LibreOffice, KOffice or Gnumeric exist. Maybe some users with DOS experience still remember Lotus or Quattro Pro. So, it is very likely that almost all spreadsheet data comes in either as CSV or in one of the Excel formats.

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re: Install on demand ?
by marto (Cardinal) on May 07, 2024 at 12:44 UTC

    Lotus 1-2-3 stopped being a supported thing 22 years ago, where in Spreadsheet::Read do you see support for the wk* formats? Obviously you need to install the modules before they can be used, this shouldn't be triggered by an on demand action.

      Lotus 1-2-3 stopped being a supported thing 22 years ago

      It was the only spreadsheet I could think of off the top of my head that isn't Excel and isn't Google Sheets!

Re: Install on demand ?
by talexb (Chancellor) on May 07, 2024 at 13:54 UTC
      Is there a way to install the modules it uses "on demand"?

    Here's what I've done in one script:

    202 my @variables = qw/User Password Url Prefix CommPlan ApiVersion/; 203 foreach my $site ( grep { $_->{'enabled'} == 1 } @{$json_config} ) { 204 205 use lib '/some/path'; 206 eval "use FOO::$site->{'module'}"; 207 208 my %variables = 209 map { $_ => eval '$' . join( '::', 'FOO', $site->{'module'}, $_ ) } 210 @variables;
    This pulls in variables for each individual website, where the website credentials are stored in modules -- which are not stored in version control, obviously. I could also have put them in json files, but I liked the idea of using a module so that I could add dated comments to remember related information.

    Alex / talexb / Toronto

    Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

Re: Install on demand ?
by swl (Parson) on May 07, 2024 at 22:08 UTC

    You could implement something based on lazy.

    However, if this is running on a server then are there reasons not to install all the optional dependencies for Spreadsheet::Read?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11159320]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-06-14 02:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.