 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Eric Azarcon Guest
|
Posted: Tue Jan 27, 2004 5:27 pm Post subject: StreamTokenizer or Replacement suggestion? |
|
|
All,
I either need help with StreamTokenizer, a suggestion for a replacemnt
library (commercial or free) that will accomplish the same thing.
I have no problem using StreamTokenizer to read files. These files may
be delimited in typical fashion (tab, comma, etc). They may or may not
have quoted text.
I am having no problem reading the file, EXCEPT when the text is not
quoted. It looks like StreamTokenizer is trying to convert it into a
number. Quoted-String, tab delimited does fine. Quoted-string comma
delimited is fine.
Any unquoted string fails.
What setting am I missing to allow me to read a string as a string,
even if it is unquoted? Do I set quoteChar('') to empty?
A file will either contain quoted-strings or unquoted strings, but not
a mixture of both. Files are coming from disparate systems, so I have
no ability to normalize them to a single format (apart from writing to
preprocess the data of course!).
Thanks!
Eric
|
|
| Back to top |
|
 |
Chris Guest
|
Posted: Wed Jan 28, 2004 9:39 am Post subject: Re: StreamTokenizer or Replacement suggestion? |
|
|
| Quote: | It looks like StreamTokenizer is trying to convert it into a number.
|
Are you sure?
If the 'string' is unquoted then StreamTokenizer *should* be returning
it as a series of white-space delimited words, which should be trivial
to re-constitute into a string when you get the next delimiter (say a
comma).
I've used this approach to handle ropey customer files that sometimes
have quoted strings and sometimes don't without any problems.
Maybe post the method that's loading the data file? Perhaps there's
something wrong with the way you've configured the tokenizer?
- sarge
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|