Hi
I have a CSV file that I wish to parse.
A typical line will look like this:
3,,"04-0501",-13000.00,,000,"DE","ATA","","","MR AJ & MRS BJ
SMITH","08/03/2004",04 0501
so I was using String[] statementElements = statementLine.split(","); to
break up each line into the individual elements.
BUT then I found a line like:
3,,"04-0501",-13119.75,,000,"DE","ATA","JONES,SA&DB","FI ZEBBO","ABC
SECURITIES(NZ)","08/03/2004",04 0501
Note the "JONES,SA&DB" though :-( So split will break that where I do not
want it to do so.
Any ideas or references that would help?
Thanks
Shane

Signature
shanemingins@yahoo.com.duplication
remove duplication
--------------------------------------------------------------------------
"Our thinking was wrong - but our tests were not. Very interesting..." -
Ron Jefrries
Roedy Green - 29 Apr 2004 03:35 GMT
>I have a CSV file that I wish to parse.
>
>A typical line will look like this:
>
>3,,"04-0501",-13000.00,,000,"DE","ATA","","","MR AJ & MRS BJ
>SMITH","08/03/2004",04 0501
see http://mindprod.com/products.html#CSV
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Real Gagnon - 29 Apr 2004 03:38 GMT
> Any ideas or references that would help?
I'm afraid that the CSV parsing can't be solved with one-line solution
except maybe by a complex regular expression.
However there are many CSV parsers available on the Net.
Here one (not tested) :
http://ostermiller.org/utils/CSV.html
Bye.

Signature
Real Gagnon from Quebec, Canada
* Looking for Java or PB snippets ? Visit Real's How-to
* http://www.rgagnon.com/howto.html
Shane Mingins - 29 Apr 2004 05:09 GMT
Thanks for the references. I also found:
http://www.objectmentor.com/resources/articles/tfd.pdf
Cheers
Shane

Signature
shanemingins@yahoo.com.duplication
remove duplication
--------------------------------------------------------------------------
"Our thinking was wrong - but our tests were not. Very interesting..." -
Ron Jefrries
Andrew Thompson - 29 Apr 2004 06:45 GMT
> "Our thinking was wrong - but our tests were not. Very interesting..." -
> Ron Jefrries
Your spelling was wrong, but Google agrees
with your attribution. Mildly interesting..
[ Jeffries - two 'f's, one 'r' ]

Signature
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Shane Mingins - 29 Apr 2004 22:25 GMT
> > "Our thinking was wrong - but our tests were not. Very interesting..." -
> > Ron Jefrries
[quoted text clipped - 3 lines]
>
> [ Jeffries - two 'f's, one 'r' ]
Opps. Sorry Ron ;-)