spreadsheet mode for emacs for tab-delimited text files - csv

what is the correct way to view and edit tab-delimited text files in emacs, as if they were a spreadsheet?
if I write tsv files in emacs by using C-q TAB, it has the annoying quirk that tabs are not equispaced. It would be nice to be able to edit cells and have emacs automatically realign it so that it appears in a column, similar to table modes. However, I do not want to make a table, I just want to edit a tsv file. I do not see how this can be done with org-mode. Is there a built in mode for this?
for example using org-mode, I can make the tabs appear equispaced, but emacs does not automatically realign the columns when one of the cells gets more text in it. what is the right way to do this?

You can use csv-mode, available from GNU ELPA. It supports both comma-separated and TAB-separated format, and is able to properly align columns. Note that the columns won't be automatically resized on-the-fly, instead you'll have to ask Emacs explicitly to re-align columns after you've edited them.

Related

Tabs are converted to column breaks... unless those tabs are copied from a web browser

Tabs are converted to column breaks when pasted into most spreadsheet programs... but not when those tabs are copied from a web browser. What's going on here?
Steps to reproduce:
Copy some tab-delimited data (example) from a browser into your clipboard
Open a Google Sheet
Click once on any cell
Paste the contents of your clipboard
Expected result:
The tabs are converted to column breaks. Pieces of text that were separated by tabs now reside in their own cells.
Actual results:
The tabs are not converted to column breaks. All text is pasted into one cell.
However... and this is where things get weird... if the tab-delimited data is first copied into a textarea (example), and then that same tab-delimited data is copied from the textarea into a Google Sheet, the tabs are converted to column breaks as expected.
Very strange indeed. Can anyone offer insight into why this happens?
Insight, yes. An explanation of why this feature has been broken for years, even with the "New Sheets"? Sorry, no.
The tab-delimited text from the pastebin example appears in the Windows clipboard like this, in "49407: HTML Format":
Contrast this with the text copied from a textarea (or a text editor; I tried the same with wordpad), which is plain "1: CF_TEXT" format:
Since there is no option to "paste as plain text" into Sheets, the HTML version of the clipboard is used (when there is one). That's nice if the HTML includes formatting that might be retained - but isn't so handy in this case.

Freeze Panes in HTML opened in Excel

My application exports data to Excel as HTML.
It saves the markup of an HTML table in a temporary file (using xls as an extension). It then asks the operating system to open that file using its native application.
Excel can open it without a problem. I have even been able to get some formatting via CSS.
I would like the top x rows not to scroll. I was wondering if there was a way of achieving a "freeze panes" effect? I have tried using the thead and tbody tags but it does not help.
I am programming this in ActionScript. However the language used to generate the markup in the text file is irrelevant. What is important is the markup itself.
I haven't tried that myself but this http://jwcooney.com/2011/09/08/generating-excel-documents-through-html-xml-and-css-part-2/ page seems to have an answer
..The x:FreezePanes and x:Panes markup in green below tells Excel to
Freeze the first row of the document..
x:FreezePanes etc. elements are documented in the "Microsoft Office HTML and XML Reference" which you can download at http://msdn.microsoft.com/en-us/library/Aa155477%28office.10%29.aspx
The x:urn:schemas-microsoft-com:office:excel namespace is also known as "XML Spreadsheet 2000"

Why do tabs line up differently in different text editors?

I keep running across a problem where source code that uses tabs to line up key/value assignments is displayed differently in different editors.
For instance, a file on Github in both the highlighted and raw versions shows the $labels array at line 55 with mis-aligned spacing. It also looks that way in Notepad.
But, that same file, copied into Aptana or Notepad++ will display the values lined up perfectly.
Why does that happen, and is it possible to create the file in such a way that it will be displayed correctly across all editors?
Depending on your settings in each editor, they will each use a different number of spaces for a tab.
Some use 2, some use 3, some use 4, and some use 6. You can see by highlighting one of the tabs in github, the tab takes up 8 spaces.
This should be adjustable in the editor.
If you create a file in an editor that uses a particular number of spaces, and view it in an editor that uses a different number of spaces, things will look different.
There has always been a debate about whether to use spaces or tabs for indentation. It's a personal preference thing, but using spaces rather than tabs will prevent this issue.
You should be able to set your editor to use spaces instead of tabs.

Disable Auto HTML Parsing in Excel 2007

I'm trying to paste some HTML code into Excel. I have a SQL query that generates HTML and inserts image and text at certain points. I then need to paste this into a single field in Excel 2007.
The problem is that Excel automatically parses the HTML and displays a full on web page, complete with styles and pictures. It also tries to spread everything over several rows and columns. This is no good, and I'd like to turn the feature off. I just need it in plain text, no formatting. I've tried paste special, formatting the cells beforehand and searching Excel options, but came up with nothing.
I've searched the net but have found surprisingly little information on the issue. Any ideas?
Thanks

Pasting HTML Columns into Spreadsheet

Suppose you have a webpage that is displaying data in columns. I'm currently separating them using &nbsp - just to put a nice little white gap in between them. But if you do it this way and paste it into Excel or OOSpreadsheet it will put them all in one column.
Is there a way to format the HTML in such a way that will allow a space to exist in a browser AND can be pasted directly into a spreadsheet?
Use tables. And if the URL is not protected, using IE you can export any table to Excel directly.
Use divs or tables.
Put a tab break between the columns. The browser will not render whitespace if it's not inside <pre> tags:
Foo \tBar \tEtc
That should make excel behave. Of course, you do not have to write \t, you can just press the TAB key :)
For some reason, I have noticed that even this might not work, but if you paste the data first into Notepad and then into Excel, it will format properly. Beats me.
Have you thought about embedding a google or zoho spreadsheet? You can then just download the excel file.