- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: How to convert text to csv or xls?
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
03-29-2006 08:40 AM
03-29-2006 08:40 AM
This has to be done at the Unix level - not from Windows...needs to be part of a script...
Thanks...Geoff
Solved! Go to Solution.
- Tags:
- csv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2006 08:43 AM
03-29-2006 08:43 AM
Re: How to convert text to csv or xls?
# tr "\t" ","
cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2006 08:50 AM
03-29-2006 08:50 AM
Re: How to convert text to csv or xls?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2006 08:50 AM
03-29-2006 08:50 AM
Re: How to convert text to csv or xls?
Basically, I want to open in Excel (or management does) and not have to do a "data" -> "Text to columns" every time....
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2006 08:57 AM
03-29-2006 08:57 AM
Re: How to convert text to csv or xls?
I would look hard at the Text::CSV Perl module.
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2006 08:57 AM
03-29-2006 08:57 AM
Re: How to convert text to csv or xls?
I took your data file and imported in excel.
Was this what you where trying to do?
open excel
file
open - pick your file
Deleminited is checked
Next
Tab
Finish.
Richard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2006 08:59 AM
03-29-2006 08:59 AM
Re: How to convert text to csv or xls?
Try this:
# perl -pe 's/(.+?)\t+/"$1",/g;s/,([^"]+?)$/,"$1"/' filename
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2006 09:02 AM
03-29-2006 09:02 AM
Re: How to convert text to csv or xls?
I agree with Clay, I would look hard to Text::CSV Perl module and/or after I would use Spreadsheet::WriteExcel to create this file.
http://search.cpan.org/~alancitt/Text-CSV-0.01/CSV.pm
http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel-2.16/lib/Spreadsheet/WriteExcel.pm
Hope this helps
Kenavo
Pat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2006 09:05 AM
03-29-2006 09:05 AM
Re: How to convert text to csv or xls?
Sandmans tr works fine.
Clay - yes - I've heard of that module - through google - I may have to look at it further..
James - yours works as well....
Kent - yours dropped the last column for some reason?
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2006 09:15 AM
03-29-2006 09:15 AM
Re: How to convert text to csv or xls?
That is going to take me a wee bit to disect....
Is there a Perl Doctor in the house? :)
Here's my script so far:
#!/bin/sh
#
# EC-Inventory-Data-Collection script
# uses data gathered by /opt/AssetCentre/asset_reporting.ksh
# which is stored in /var/opt/AssetCentre/reports
#
#
RPTDIR=/var/opt/AssetCentre/reports
TMPFIL=/tmp/EC-Inventory-Data.txt
CSV=/htdocs/mambo/dmdocuments/Infrastructure/Server-Planning/EC-Inventory-Data-Collection.csv
if [ -f $CSV ] ;
then
cp -p $CSV $CSV.old
fi
cat $RPTDIR/label > $TMPFIL
for SERVER in `ls $RPTDIR/*.value`
do
cat $SERVER >> $TMPFIL
done
tr "\t" "," <$TMPFIL >$CSV
The SERVER.value (tab delimited) files are created from another script - all I want to do is gather all that individual info and put it in a spreadsheet...
Thanks...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2006 09:24 AM
03-29-2006 09:24 AM
Re: How to convert text to csv or xls?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2006 09:25 AM
03-29-2006 09:25 AM
Re: How to convert text to csv or xls?
You wanted a free way to create excel worksheet on unix.
From CPAN :
Spreadsheet::WriteExcel will work on the majority of Windows, UNIX and Macintosh platforms.
Regards
Pat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2006 09:32 AM
03-29-2006 09:32 AM
Re: How to convert text to csv or xls?
http://sedition.com/perl/delim-to-excel.html
http://www-128.ibm.com/developerworks/library/l-pexcel/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2006 11:33 AM
03-29-2006 11:33 AM
Re: How to convert text to csv or xls?
# awk -F"\t" '{
> for (i=1;i<=NF;++i) printf((i
cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2006 11:48 AM
03-29-2006 11:48 AM
Re: How to convert text to csv or xls?
Much the same question was recently discussed in under the somewhat vague title: "AWK - FS and output" :
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1008954
>> Is there a Perl Doctor in the house? :)
Several. What nationality would you prefer? :-)
>> Basically, I want to open in Excel (or management does) and not have to do a "data" -> "Text to columns" every time....
I feel your pain... but not theirs.
When I open a .TXT with Excel 'it' suggests to interpret it as tab-seperated and all I need to do is click 'finish'.
Moreover... once I am in a such spreadsheet I can just paste in new tab-seperated text and 'it does the right thing'
Cheers,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2006 01:35 AM
03-30-2006 01:35 AM
Re: How to convert text to csv or xls?
If your file is built with the output of a script, maybe ou could tweak the output so that you can just save the output file with a name of blahblah.xls and then you could just email the attachment and viola!
I couldn't tell from the content what application you are using to extract that data. But as an example, PerfView used to have an export to csv option that allowed me to save graph output to files named blahblah.xls. OVPA extracts operate much the same way. The xls files opened right up. I still use the extract command to do my management graphs - no conversion tricks necessary. You just have to watch how you transfer the file. You may expect it to be a text file, but once you treat it as an xls file you need to transfer it binary. But it looks like your file has data extracted from a script, so that all may be a moot point.
Of course, if I knew squat about Perl, I think I'd lean toward that option. But I don't, so I try crazy stuff and sometimes it works. :-) I need to get into some Perl, man...
Good luck!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2006 01:41 AM
03-30-2006 01:41 AM
Re: How to convert text to csv or xls?
Have you looked at my own module Spreadsheet::Read? It comes with xlscat, a small script to convert all kinds of spreadsheet like formats to plain text or csv
http://search.cpan.org/~hmbrand/Spreadsheet-Read-0.14/
It also has a util to show csv in a perl/Tk spreadsheet form.
If you also want a script to convert CSV to XLS, I can give that on request, as I use that on a daily basis.
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2006 01:49 AM
03-30-2006 01:49 AM
Solutionhttp://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=746822
discusses conversion to xls format as well. Solution seems to have been to use perl module.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2006 01:59 AM
03-30-2006 01:59 AM
Re: How to convert text to csv or xls?
> csv2xls --help
usage: csv2xls [-s
[-o
-s
-q
-w
-o
to input file name with .csv replaced with .xls
if from standard input, defaults to csv2xls.xls
-f force usage of
-d
That should be enough for you :)
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2006 03:05 AM
03-30-2006 03:05 AM
Re: How to convert text to csv or xls?
Had to also File-Temp-0.16 and Parse-RecDescent-1.94 following John's "method 1" instructions here:
http://search.cpan.org/src/JMCNAMARA/Spreadsheet-WriteExcel-2.14/doc/install.html
Thanks all!
Rgds...Geoff