how to work with tab-delimited files?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Salerno

    #1

    how to work with tab-delimited files?

    When you're using tabs to separate values in a text file, what do you do
    in the case where pressing the tab key doesn't really advance the cursor
    a full tab space (but instead just one or two spaces) because that's
    where the next tab stop is?

    Example:

    Joe Smith
    John Salerno

    So the second entry has a full tab space between the names, but the
    first doesn't, despite the fact that the tab key was pressed. So in this
    situation, when the file is being read, is that single space still
    determined to be a tab, or do you have to press tab twice to put a full
    tab between the names?

    Thanks.
  • Paddy

    #2
    Re: how to work with tab-delimited files?

    Hmm,
    check your editor to see if it has an option to display non-printable
    characters, or see if you can search for tabs in its find utility.

    If you find that your editor has the ability to insert spaces instead
    of tabs then turn it off.

    Thats all that comes to mind...


    - Pad.

    Comment

    • Tim Chase

      #3
      Re: how to work with tab-delimited files?

      > So in this situation, when the file is being read, is that[color=blue]
      > single space still determined to be a tab, or do you have to
      > press tab twice to put a full tab between the names?[/color]

      If there is a literal tab in the file, it will come in (to your
      code) as a real tab.

      Your editor may have settings you can tweak to make it a little
      more apparent. Vim (my preferred poison) allows you to

      :set list

      to see representations the literal tabs in your file. To turn it
      off, do

      :set nolist

      You can also tweak your tabstops:

      :set ts=12

      (or whatever number/size accomodates your widest columns) which
      would make a single tab character expand to your desired size.
      This should help line matters up visually a little better.

      Alternatively, with vim you can highlight the tabs to make them
      stand out a bit more:

      :match ErrorMsg /\t/

      (or you can use another color instead of the ErrorMsg color...if
      you hit <tab> after typing ":match ", it will successively show
      you alternatives, or you can use ctrl+D to show a number of them)

      Just a few ideas with a vim spin. Other quality editors should
      support similar functionality.

      -tkc



      Comment

      • John Salerno

        #4
        Re: how to work with tab-delimited files?

        Tim Chase wrote:[color=blue][color=green]
        >> So in this situation, when the file is being read, is that
        >> single space still determined to be a tab, or do you have to
        >> press tab twice to put a full tab between the names?[/color]
        >
        > If there is a literal tab in the file, it will come in (to your code) as
        > a real tab.[/color]

        Yeah, after viewing the unprintable characters, I see that no matter
        what the spacing, there is a tab character between the values. I guess
        what might be confusing me is the difference between Tab Stop Value and
        Indent Spaces in my editor.

        Comment

        Working...