how to work with tab-delimited files?

J

John Salerno

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.
 
P

Paddy

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.
 
T

Tim Chase

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?

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
 
J

John Salerno

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

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top