Cutting Columns

Posted:
in macOS edited January 2014
One feature that I need sometimes is the ability to cut and paste vertically. Doing this in spreadsheets is easy but impossible in other documents. Am I alone in this need? It seems to me that this would be as needed as horizontal cutting and pasting.

Comments

  • Reply 1 of 4
    lundylundy Posts: 4,466member
    Quote:

    Originally posted by ThinkingDifferent

    One feature that I need sometimes is the ability to cut and paste vertically. Doing this in spreadsheets is easy but impossible in other documents. Am I alone in this need? It seems to me that this would be as needed as horizontal cutting and pasting.



    MS Word has always supported this as option-drag to select a vertical chunk of text. So if you have MS Word you could transfer text documents in there.
  • Reply 2 of 4
    You can in fact option-drag to select text in any OS X application. I love this feature.
  • Reply 3 of 4
    Quote:

    Originally posted by Sladuuch

    You can in fact option-drag to select text in any OS X application. I love this feature.



    I just tried that in Safari and it didn't work.
  • Reply 4 of 4
    toweltowel Posts: 1,479member
    If you're working with text documents, you can use cut and paste on the command line to do this. They can be a lot faster and less aggravating than firing up Excel.



    Say you're working with two tab-delimited text files with data in columns. To copy the fourth column of file1 and attach it as the last column in file2:
    Code:


    cut -f 4 file1 > temp

    paste file2 temp > newfile2



    There's a variety of options for both commands that let you get exactly the input and output you want. They're incredibly versatile, and not too difficult to figure out if you've been around Terminal before.



    Copying text out of HTML table columns is much more difficult, because the data aren't actually arranged in columns in the HTML source. You need a program that can recognize an HTML table, count the various row and element tags in it, and match up the contents of the appropriate element tags. Interestingly, and strangely, I find that most plain-text editors can do this. If you highlight a web-page table, copy it, and paste into SubEthaEdit or a TextEdit document that you've specified as plain-text, it will appear in the expected format, with tabs between elements. You can then either copy-and-paste the tab-delimited text into Excel, or save it in text files and do your command-line cut and paste magic on it. On the other hand, if you try copy-and-pasting web tables directly into Excel, Word, or an RTF TextEdit document, the contents appear as a single-column list - they lose all table formatting.



    There's also various programs and scripts floating about on the web for extracting tables from HTML and saving them as delimited text files. I wrote a quick one myself in Perl, which I'm happy to share if you're interested.



    (I know this stuff, and feel your pain, because part of my job over the last year has been extracting particular data from HTML tables, rearranging them, and converting to a more reasonable format. Pain in the ass.)
Sign In or Register to comment.