- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- PERL .csv file new sheet
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2006 05:33 AM
12-29-2006 05:33 AM
PERL .csv file new sheet
I have written a PERL script to create a .csv file and write some data in it. Now I want to use a different file handle and create a new worksheet in the same .csv file and write data in it.
Can anyone please let me know how to accomplish the task.
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2006 05:59 AM
12-29-2006 05:59 AM
Re: PERL .csv file new sheet
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2006 06:22 AM
12-29-2006 06:22 AM
Re: PERL .csv file new sheet
You'll need the Spreadsheet::WriteExcel perl module.
my $workbook = Spreadsheet::WriteExcel->new('filename.xls');
my $worksheet = $workbook->add_worksheet();
$worksheet->write(0, 0, "Hi Excel!");
http://search.cpan.org/dist/Spreadsheet-WriteExcel/
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2006 08:05 AM
12-29-2006 08:05 AM
Re: PERL .csv file new sheet
Anand>> create a new worksheet in the same .csv file
Merijn>> You can't. CSV does not support multiple sheets.
Right, but I don't like the wording.
You can do anything you darn well please in a .csv file.
It supports anything you can imagine and code up.
It could easily support a notion that a row/line/record with
However, do not expect EXCEL to interpret the data thusly.
Microsoft EXCEL only supports a single worksheet in a csv file.
If you want more, you'll have to code to a format for which excel support worksheets.
Anand,
May we assume that you want to feed the csv file to excel? Then use the perl Spreadsheet::WriteExcel moduel as Spex indicate, or figure out how to write XML instead of CSV.
Hint: Go into EXCEL, create a simple spreadsheet with two or three worksheets, a few columns and data lines each, no formatting or formulas (to begin with) and SAVE AS ... .XML.
No open the result with NOTEPAD.
Hope this helps,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2006 08:32 AM
12-29-2006 08:32 AM
Re: PERL .csv file new sheet
CSV does not support multiple sheets. period.
Any other format M$Excel, OpenOffice Calc, Improv, Oleo, XML, ... does, but csv does not
For all the others there are indeed fine modules, well, maybe not for oleo, but still. And CSV is not, and does not support, (embedded) XML.
Write two files: sheet1.csv, and sheet2.csv: see: two sheets, both obeing the specs (if you've used COMMA's and not M$'s semi-colons, and correct quoting, which is easily achieved using Text::CSV_XS or Text::CSV.
BTW *REAL* CSV has \r\n on the line ending, something violated quite often too.
Enjoy, Have FUN! H.Merijn [ A heavy CSV user ]