LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-08-2012, 01:06 PM   #1
graphicsmanx1
Member
 
Registered: Oct 2012
Posts: 81

Rep: Reputation: Disabled
Can you echo results to an excel file


I realized I could print results to a .csv but I wanted to know if I could print results to certain columns and rows I assign. I thought that would be something fun to learn.
 
Old 11-08-2012, 01:34 PM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
look into awk for any column parsing functionality.

also supposedly there are some perl utilities out there that can convert .csv files into binary coompatable .xcl ms-excel formatted files.
 
Old 11-08-2012, 04:37 PM   #3
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
I agree with schneidz, it could be easily done with Perl, probably it would be good if you posted an example-file and explain your problem in more detail.

Markus
 
Old 11-09-2012, 08:34 AM   #4
graphicsmanx1
Member
 
Registered: Oct 2012
Posts: 81

Original Poster
Rep: Reputation: Disabled
well I thought it would be cool if I echoed items and could place them columns and rows in excel. Not long ago I started learning how to use imagemagick and some its features. I started setting thing as variables and I thought it would be fun to learn how to set each variable in a column and start a new row. I dont really have anything just something I wanted to learn.
 
Old 11-09-2012, 08:47 AM   #5
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Well, I think independent from the language or command you use, the way to put data into a csv-file will always be, to split the line and putting the data into a list. As an example (Perl-code), when the delimiter in the lines is a ";"
Code:
my @data = split /;/, $line ;
afterwards @data (an Array) holds the data of the fields between the ";"
Now one could substitute (or set) the data
Code:
$data[3]="my new data" ;
would put the text "my new data" into the fourth field of the array.
and join the array to a string
Code:
$newline = join /;/, @data ;
There are also solutions possible with sed or awk.

Markus
 
1 members found this post helpful.
Old 11-09-2012, 09:40 AM   #6
graphicsmanx1
Member
 
Registered: Oct 2012
Posts: 81

Original Poster
Rep: Reputation: Disabled
someone else also mentioned awk. Can you point where some good tutorials and reads would be for awk as well?
 
Old 11-09-2012, 10:09 AM   #7
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
There are several places in the internet with tutorials about bash and awk, take also a look at sed.

http://bashshell.net/stream-filterin...ng-awk-basics/
http://www.delorie.com/gnu/docs/gawk...l#SEC_Contents
http://tldp.org/LDP/abs/html/awk.html but here's also the whole tutorial (which actually is an advanced bash-guide) very valuable http://tldp.org/LDP/abs/html/

I learned sed with this tutorial http://www.grymoire.com/Unix/Sed.html

Maybe it would be useful to purchase a book, normally a good book about bash will also have chapters with awk and sed.

Markus
 
1 members found this post helpful.
Old 11-09-2012, 12:34 PM   #8
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
A little off-topic. A csv-file is not the same as an excel-file
 
Old 11-09-2012, 12:37 PM   #9
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Quote:
Originally Posted by Wim Sturkenboom View Post
A little off-topic. A csv-file is not the same as an excel-file
Yes, that's true, but Excel can open csv-files and one can also save an Excel-file as csv-file. I don't think that your post is off topic, id could have been mentioned earlier in this thread

Markus
 
Old 11-09-2012, 12:55 PM   #10
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
thats a good point... ascii (including .csv or .xml) is the most trans-portable format so dealing with .csv (which ms-excel can handle) is easier with trying to translate .xcl files into ascii without a gui.

i remember using a program that would transform open-office odf into ms-excel format (so you can do hundreds at a time) but i forget what it was called.
 
Old 11-09-2012, 01:10 PM   #11
graphicsmanx1
Member
 
Registered: Oct 2012
Posts: 81

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by markush View Post
There are several places in the internet with tutorials about bash and awk, take also a look at sed.

http://bashshell.net/stream-filterin...ng-awk-basics/
http://www.delorie.com/gnu/docs/gawk...l#SEC_Contents
http://tldp.org/LDP/abs/html/awk.html but here's also the whole tutorial (which actually is an advanced bash-guide) very valuable http://tldp.org/LDP/abs/html/

I learned sed with this tutorial http://www.grymoire.com/Unix/Sed.html

Maybe it would be useful to purchase a book, normally a good book about bash will also have chapters with awk and sed.

Markus
Ive looked for good books but didnt find anything worth wild
 
Old 11-09-2012, 10:09 PM   #12
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
Quote:
Originally Posted by graphicsmanx1 View Post
Ive looked for good books but didnt find anything worth wild
sed & awk is in my cupboard
 
Old 11-10-2012, 08:13 PM   #13
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 952

Rep: Reputation: 217Reputation: 217Reputation: 217
See, excel has its own proprietary format. So you need specific modules to post your data into excel format and that includes specific rows and columns.

I believe that perl has just such modules. awk as such doesn't have the functionality that you need.

OK
 
Old 11-10-2012, 08:45 PM   #14
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
How about a script to
  1. Write a LibreOffice macro to populate the cells.
  2. Start LibreOffice with a command that opens the Excel file and runs the macro.
If you don't want the Excel file left open, the macro could also save and exit.

If you don't want to see the Excel file on screen, you could start LibreOffice headless.
 
Old 11-14-2012, 11:20 PM   #15
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
i see this. not sure if it goes the other way:
Code:
xlhtml.x86_64 : Excel 95/97 and PowerPoint to HTML converter
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading one EXCEL(.xls) file and writing to other EXCEL(.xls) file vijay mishra General 6 04-23-2012 07:53 PM
How to copy Arabic data from excel fiel to another excel file in PERL? David the H. Linux - Newbie 0 04-23-2012 09:24 AM
Convert from XML in excel format to Excel XLS file CPAN module Perseus Programming 9 10-14-2011 12:39 PM
How to echo results of variable BabaKali Linux - Newbie 7 11-10-2004 12:47 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration