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.
|
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. |
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 |
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.
|
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 ; Now one could substitute (or set) the data Code:
$data[3]="my new data" ; and join the array to a string Code:
$newline = join /;/, @data ; Markus |
someone else also mentioned awk. Can you point where some good tutorials and reads would be for awk as well?
|
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 |
A little off-topic. A csv-file is not the same as an excel-file ;)
|
Quote:
Markus |
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. |
Quote:
|
Quote:
|
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 |
How about a script to
If you don't want to see the Excel file on screen, you could start LibreOffice headless. |
i see this. not sure if it goes the other way:
Code:
xlhtml.x86_64 : Excel 95/97 and PowerPoint to HTML converter |
I thinks probably it would be good if you posted an example-file and explain your problem in more detail.
|
actually this doesnt work too bad. I was playing around and it worked for A code I made for fun:
Code:
echo $variable,$variable,$variable >> file.csv Code:
name=$(basename $target) |
file.csv is actually a TEXT file containing comma separated values. IT DOESN'T STORE DATA ABOUT THE DESTINATION FILE'S ROWS AND COLUMNS.
Microsoft and indeed most other spreadsheet programs(like open office and libre office) provide a way to open the data so that it can be used like a spreadsheet. OK |
Quote:
|
The original discussion was about excel and whether csv files can have row and column ids embedded in them.
Quote:
I am concerned that that this default opening of csv files by msexcel has led to a general dumbing down of knowledge about file formats so that people dont know that CSV is a plain human readable format and we can use many command line utilities that predate msexcel (like awk and sed) to to open and interpret the contents. Even in your redirection example (post #17 in this thread), the destination row and column numbers cant be stored in the csv file. If you open your spreadsheet and position the cursor in any arbitrary cell say cell "b25", say and import the data by pasting, it will be imported into cell b25 onwards. You are not assigning the desired cell in the csv file. OK |
graphicsmanx1, did you consider AnanthaP's suggestion to look for perl modules that are capable of working with Excel's proprietary format or my suggestion to use LibreOffice's facilities to do the same? Or are you happy to use the CSV route?
|
I like the CSV but I will learn the proper way to do it. Many good ideas
|
Perl can do this as can Python try xlwt if you go the python root not sure in perl but CPAN will have it
|
All times are GMT -5. The time now is 10:23 AM. |