I was wondering what is the best way to import Excel tables into Latex file using Textmate? I tried copy/pasting a table into Textmate, then using "Convert Selection to Table". However, this does not result in a correctly formatted table due to the way the Excel table is pasted. Anyone have experience/solution for this? Thanks
Will
Will,
an interesting question I was thinking about last night as well. I haven't tested this, but exporting as csv (comma separated or any other symbol is posssible, I believe) opens up all kinds of possibilities with TextMate's regex search…?
btw and very OT: … is there any alternative to excel on the mac? a) for calculating and b) for plotting?
Dan
Daniel Käsmayr wrote:
Will,
an interesting question I was thinking about last night as well. I haven't tested this, but exporting as csv (comma separated or any other symbol is posssible, I believe) opens up all kinds of possibilities with TextMate's regex search…?
btw and very OT: … is there any alternative to excel on the mac? a) for calculating and b) for plotting?
Dan
I was hoping for something simpler since I work with small tables...something like copy table into Textmate, click convert, and boom, Latex table. I modified the existing Convert Table script to work with Excel and it works for my needs, but probably misses many corner cases. If anyone has a better solution please post. Thanks
Will
#!/usr/bin/perl -w $line=<>; $count=0; $line=~s/^\s+//; while ($line=~s/(\w)\t+(\w)/$1 & $2/) { $count++; } $line=~s/\n/\\\n/; $greeting="\table[ht]\n"; $greeting.="\t\centering\n"; $greeting.="\t\begin{tabular}{"; for (0..$count) { $greeting.="c"; } $greeting.="}\n"; print $greeting; $hline="\t\hline\n"; print $hline."\t".$line.$hline; while ($line=<>) { $line=~s/^\s+//; $line=~s/\t+/ & /g; $line=~s/\n/\\\n/; print "\t$line"; } print "\\\n".$hline."\t\end{tabular}\n"; print "\t\caption{Table Caption}\n"; print "\t\label{Table Label}\n"; print "\end{table}\n";
Will, On Oct 1, 2006, at 2:15 PM, William Yang wrote:
Daniel Käsmayr wrote:
Will, an interesting question I was thinking about last night as well. I haven't tested this, but exporting as csv (comma separated or any other symbol is posssible, I believe) opens up all kinds of possibilities with TextMate's regex search…? btw and very OT: … is there any alternative to excel on the mac? a) for calculating and b) for plotting?
Ok, first answering Daniel's OT question: There is the R language, depending on what you want to do. I will probably use it for most of my spreadsheeting needs. http://www.r- project.org/
Dan
I was hoping for something simpler since I work with small tables...something like copy table into Textmate, click convert, and boom, Latex table. I modified the existing Convert Table script to work with Excel and it works for my needs, but probably misses many corner cases. If anyone has a better solution please post. Thanks
So, could you explain to us why just copying and pasting from Excel didn't work for you? I don't have Excel on my mac to test, but the Excel in my windows machine seems to paste the cells as being tab- delimited, which IIRC is what the convert macro expects, so it would seem you wouldn't need to do anything at all differently. So could you show us the pasted Excel text that wasn't working for you? (You can use the Pastie service, i.e. select the text in textmate, and press ctrl-shift-opt-V, then paste the resulting link here.
Will
Haris
Charilaos Skiadas wrote:
Will, On Oct 1, 2006, at 2:15 PM, William Yang wrote:
Daniel Käsmayr wrote:
Will, an interesting question I was thinking about last night as well. I haven't tested this, but exporting as csv (comma separated or any other symbol is posssible, I believe) opens up all kinds of possibilities with TextMate's regex search…? btw and very OT: … is there any alternative to excel on the mac? a) for calculating and b) for plotting?
Ok, first answering Daniel's OT question: There is the R language, depending on what you want to do. I will probably use it for most of my spreadsheeting needs. http://www.r-project.org/
Dan
I was hoping for something simpler since I work with small tables...something like copy table into Textmate, click convert, and boom, Latex table. I modified the existing Convert Table script to work with Excel and it works for my needs, but probably misses many corner cases. If anyone has a better solution please post. Thanks
So, could you explain to us why just copying and pasting from Excel didn't work for you? I don't have Excel on my mac to test, but the Excel in my windows machine seems to paste the cells as being tab-delimited, which IIRC is what the convert macro expects, so it would seem you wouldn't need to do anything at all differently. So could you show us the pasted Excel text that wasn't working for you? (You can use the Pastie service, i.e. select the text in textmate, and press ctrl-shift-opt-V, then paste the resulting link here.
Will
Haris
http://pastie.caboo.se/15703 But this doesn't seem to preserve the tabs?
Here it is pasted directly:
Size GCC IPC GZIP IPC 1024 0.8026 0.1987 2048 0.8031 0.1987 4096 0.8025 0.1987 32768 0.8026 0.1987
This is what the "Convert table.." in the Latex bundle output:
\begin{tabular}{cc} \hline Size & GCC IPC GZIP IPC\ \hline 1024 & 0.8026 & 0.1987\ 2048 & 0.8031 & 0.1987\ 4096 & 0.8025 & 0.1987\ 32768 & 0.8026 & 0.1987\ \hline \end{tabular} The numbers are parsed right, but the title is not.
This is how my script outputs, which is the correct one: \table[ht] \centering \begin{tabular}{ccc} \hline Size & GCC IPC & GZIP IPC\ \hline 1024 & 0.8026 & 0.1987\ 2048 & 0.8031 & 0.1987\ 4096 & 0.8025 & 0.1987\ 32768 & 0.8026 & 0.1987\ \hline \end{tabular} \caption{Table Caption} \label{Table Label} \end{table}
Will
Daniel Käsmayr wrote:
Will,
an interesting question I was thinking about last night as well. I haven't tested this, but exporting as csv (comma separated or any other symbol is posssible, I believe) opens up all kinds of possibilities with TextMate's regex search…?
btw and very OT: … is there any alternative to excel on the mac? a) for calculating and b) for plotting?
Dan
And about your OT: how about Openoffice (or NeoOffice)? They have a pretty robust spreadsheet program from my limited use.
Will
On Oct 1, 2006, at 5:16 PM, William Yang wrote:
And about your OT: how about Openoffice (or NeoOffice)? They have a pretty robust spreadsheet program from my limited use.
They are way too bloated in my opinion, for most uses. In my computer, Openoffice takes a full 2 minutes to load, and similar performance for NeoOffice, and their memory demands are huge as well. If I just want to add 10 numbers, I shouldn't have to go through all that. ( I guess that's why I created my Spreadsheet bundle for textmate).
From my point of view they serve essentially one purpose: To allow one to open Microsoft Office files without having Microsoft Office.
Anyway, to return to the script question, I just committed a simpler version of the script, in Ruby, that should work just fine with your case. Let me know how it works (if you follow the repository version of the LaTeX bundle that is.)
Will
Haris
Charilaos Skiadas wrote:
On Oct 1, 2006, at 5:16 PM, William Yang wrote:
And about your OT: how about Openoffice (or NeoOffice)? They have a pretty robust spreadsheet program from my limited use.
They are way too bloated in my opinion, for most uses. In my computer, Openoffice takes a full 2 minutes to load, and similar performance for NeoOffice, and their memory demands are huge as well. If I just want to add 10 numbers, I shouldn't have to go through all that. ( I guess that's why I created my Spreadsheet bundle for textmate).
From my point of view they serve essentially one purpose: To allow one to open Microsoft Office files without having Microsoft Office.
Anyway, to return to the script question, I just committed a simpler version of the script, in Ruby, that should work just fine with your case. Let me know how it works (if you follow the repository version of the LaTeX bundle that is.)
Will
Haris
Works great. Only thing is, if there is a tab in the very beginning then it would add a "&" even though it is not needed. Would it be useful to remove tabs at the beginning and end of the line first? Thanks
Will
On Oct 1, 2006, at 7:10 PM, William Yang wrote:
Works great. Only thing is, if there is a tab in the very beginning then it would add a "&" even though it is not needed. Would it be useful to remove tabs at the beginning and end of the line first? Thanks
Done. It now removes any whitespace (spaces, tabs, newlines) from the beginning and the end of the entire selection.
Will
Haris
Charilaos Skiadas wrote:
On Oct 1, 2006, at 7:10 PM, William Yang wrote:
Works great. Only thing is, if there is a tab in the very beginning then it would add a "&" even though it is not needed. Would it be useful to remove tabs at the beginning and end of the line first? Thanks
Done. It now removes any whitespace (spaces, tabs, newlines) from the beginning and the end of the entire selection.
Will
Haris
Hmmm...not sure if I have the latest version, but although the first row has the whitespace fixed, subsequent rows doesn't seem to have whitespace removed.
Thanks, Will
On Oct 1, 2006, at 7:36 PM, William Yang wrote:
Hmmm...not sure if I have the latest version, but although the first row has the whitespace fixed, subsequent rows doesn't seem to have whitespace removed.
No, subsequent rows wouldn't, because I was sort of thinking that perhaps people would like to have an empty cell in the first column at places. I can easily adjust it if this is not likely. The current script allows for empty cells except for the top left and bottom right one.
Thanks, Will
Haris
Charilaos Skiadas wrote:
On Oct 1, 2006, at 7:36 PM, William Yang wrote:
Hmmm...not sure if I have the latest version, but although the first row has the whitespace fixed, subsequent rows doesn't seem to have whitespace removed.
No, subsequent rows wouldn't, because I was sort of thinking that perhaps people would like to have an empty cell in the first column at places. I can easily adjust it if this is not likely. The current script allows for empty cells except for the top left and bottom right one.
Thanks, Will
Haris
How about only remove whitespace in the beginning if the first line also had it?
Will
On Oct 1, 2006, at 8:47 PM, William Yang wrote:
How about only remove whitespace in the beginning if the first line also had it?
That would complicate the code somewhat, and I guess after all if someone really needs this they can add the entries themselves by just putting an ampersand in at the beginning. So i just changed it to remove the spaces from the beginning and end of every line.
Will
Haris
On 1/10/2006, at 7:35, William Yang wrote:
I was wondering what is the best way to import Excel tables into Latex file using Textmate? I tried copy/pasting a table into Textmate, then using "Convert Selection to Table". However, this does not result in a correctly formatted table due to the way the Excel table is pasted. Anyone have experience/solution for this? Thanks
If you paste the table (see Bundles → TextMate → Paste to Paste Bin…) it might be possible to adapt the Convert Selection to Table to work with your input (or at least say why it doesn’t work)
The simplest (non-textmate solution) is to use the Excel macro excel2latex to be found here: http://www.jam-software.com/freeware/index.shtml
(It's home page has gone but it seems to be lying around the Web) It generates the correct text which you can copy and paste into your latex file. Not perfect but very good for simple tables.
Christopher
***************************************************** Natural Language Processing Group, Department of Computer Science, University of Sheffield
On 1 Oct 2006, at 06:35, William Yang wrote:
I was wondering what is the best way to import Excel tables into Latex file using Textmate? I tried copy/pasting a table into Textmate, then using "Convert Selection to Table". However, this does not result in a correctly formatted table due to the way the Excel table is pasted. Anyone have experience/solution for this? Thanks
Will
______________________________________________________________________ For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
On Sep 30, 2006, at 22:35, William Yang wrote:
I was wondering what is the best way to import Excel tables into Latex file using Textmate? I tried copy/pasting a table into Textmate, then using "Convert Selection to Table". However, this does not result in a correctly formatted table due to the way the Excel table is pasted. Anyone have experience/solution for this? Thanks
I use Tabular.xla for this: http://tabular.hsh.no/, which works up through Excel 2004.
Adam