Compare 2 Tab Delimited

N

Nick

Hi,

I need to compare 2 tab demilited files. The row order might differ.
So my plan is to convert them into some objects and then compare the
two objects.

Any better suggestion. And how do I extract the records from the tab
de milited file using Java


Please help !

Cheers
Nick
 
C

Chase Preuninger

I don't like the idea of tab delimited files. Use something else like
a comma or semicolon.
 
J

Jussi Piitulainen

Nick said:
And how do I extract the records from the tab
de milited file using Java

Read each line in. Use a BufferedReader and its readLine() method for
this. Break the loop when you get null.

Split a tab-delimited String into a String[] with the split("\t", n)
method of String if you know the number of fields n, or just
split("\t") if you don't know and don't care about possible trailing
empty fields being lost.

See javadoc for java.io.BufferedReader and java.lang.String.
 
A

Arved Sandstrom

Chase Preuninger said:
I don't like the idea of tab delimited files. Use something else like
a comma or semicolon.

I'm a little curious as to what you have against tabs. The problem with
commas or semicolons or colons is that now you have to quote fields with
those characters, then handle the situation of the quote character being in
the fields too...namely, our favourite CSV flatfile format. Tabs as part of
your data is much less common, so it's a good delimiter. You normally don't
manually insert the tabs anyway, and any decent text editor has a "Show
whitespace" option if you find that necessary.

AHS
 
L

Leonard Milcin

Arved said:
I'm a little curious as to what you have against tabs. The problem with
commas or semicolons or colons is that now you have to quote fields with
those characters, then handle the situation of the quote character being in
the fields too...namely, our favourite CSV flatfile format. Tabs as part of
your data is much less common, so it's a good delimiter. You normally don't
manually insert the tabs anyway, and any decent text editor has a "Show
whitespace" option if you find that necessary.

Well. Even with ,,show whitespace'' it is usually difficult to say if
something is a tab or a space and it is quite easy to escape special
characters properly.

Regards,
Leonard
 
A

Arne Vajhøj

Leonard said:
Well. Even with ,,show whitespace'' it is usually difficult to say if
something is a tab or a space and it is quite easy to escape special
characters properly.

It is easier to write tab separated files by programs.

But it is more difficult to read tab separated files by humans.

Arne
 
A

Arved Sandstrom

Leonard Milcin said:
Well. Even with ,,show whitespace'' it is usually difficult to say if
something is a tab or a space and it is quite easy to escape special
characters properly.

Regards,
Leonard

It would depend on the editor. On the Windows side, Notepad++ shows tabs as
tabs (an arrow, actually) if you select "Show WS and Tabs", and you don't
have "Replace by space" set for tabs.

As for escaping, sure, it's not so tough. But why do it at all?

AHS
 

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

Forum statistics

Threads
474,001
Messages
2,570,249
Members
46,846
Latest member
BettinaOsw

Latest Threads

Top