Operating System - HP-UX
1751815 Members
5711 Online
108781 Solutions
New Discussion юеВ

Re: Converting csv to xls using raw unix shell script

 
ABUL HASIM
New Member

Converting csv to xls using raw unix shell script

Hi,

I know about some perl module which can do this.
But I dont have root access to install those modules.
Thus want some idea how we can do that by unix shell scripting only.

Thanks for your help in advance.

Regards,
Hasim
5 REPLIES 5
James R. Ferguson
Acclaimed Contributor

Re: Converting csv to xls using raw unix shell script

Hi Hasim:

> I know about some perl module which can do this. But I dont have root access to install those modules. Thus want some idea how we can do that by unix shell scripting only.

I'm glad that you know about Perl and its modules. Not having root access to install them should not be a deterrent. Either ask your system administrator to do this for you; _OR_ install them in your ${HOME} directory. By default, Perl includes your current path in @INC.

Doing this without the Perl module support is not going to be trivial.

Regards!

...JRF...
Mel Burslan
Honored Contributor

Re: Converting csv to xls using raw unix shell script

Against the risk of pointing the obvious, why in the world do you need to do this ? If you have a comma delimited file, saved as *.csv and you have a recent enough (last 5 years or maybe even more) version of MS Excel, you have the file association for the *.csv, set to excel by default.

If you have an application which gets its input from xls files, then you might want to consider using something like authotkey to open this document in excel and saving it as xls file on the PC side. Look for *.ahk scripts flourishing around the web for that.

I am sorry but as JRF also said, tackling Microsoft's proprietary binary formats is not a picnic in the park.
________________________________
UNIX because I majored in cryptology...
OldSchool
Honored Contributor

Re: Converting csv to xls using raw unix shell script

"..tackling Microsoft's proprietary binary formats is not a picnic in the park."

read that as "just plain ugly".

and just for fun, yahoo turns up 450,000+ hits on "unix convert csv to xls", the first two pages of which actually talk about going from xls to csv...

somebody already did the work in a perl module, it makes sense to use that (if you absolutely have to do the conversion).

As previously noted, with most later installations, double clicking a .csv file will cause it to open in Excel anyway, so I don't see much advantage to doing this.
James R. Ferguson
Acclaimed Contributor

Re: Converting csv to xls using raw unix shell script

Hi (again) Hasim:

...and I misread this as a CSV format to XML (instead of XLS, since after all this is UNIX), so as Mel said, just import your file into M$ Excel and be done!

...JRF...
H.Merijn Brand (procura
Honored Contributor

Re: Converting csv to xls using raw unix shell script

Just import into XLS has three ways from CSV and they all behave differently

* Double-click on the CSV file
* Open .CSV file from Excel
* Data->import from Excel

The first two will incorrectly ignore all quotation and do conversions you don't want or expect

1,"12-11-2009",booz

will translate the second field to Dec/11/2009, something obviously NOT intended (it's quoted, right, it is a string).

When using (perl) scripts to convert CSV to XLS, those things can easily be controlled.

My module Spreadsheet::Read comes with a csv2xls convertor with many options.
As others already mentioned, you don't need root access to install them

$ export PERL5LIB=$HOME/perl5/lib:$HOMe/perl5/arch

might be all you need to access your modules installed in ~/perl5

HTH, Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn