Removing rogue ciarraige returns in data file

From: Jonathan (jonathan_at_bakerbates.SPAMGONE.com)
Date: 08/20/03


Date: Wed, 20 Aug 2003 12:31:43 +0100

Hi,

I'm having a hard time with a CSV file that has carriage returns in a postal
address field, making the number of columns vary. Has anyone got any
pointers on how I can mend this?

For example, the data looks like this right now:

field1,field2,field3,field4,field5
field1,field2,field3,field4,field5
field1,field2,field3
,field4,field5
field1,field2,field3,field4,field5

(Note the CR at the end of field3 in the column 3)

I'd like to fix it so it looks like this:

field1,field2,field3,field4,field5
field1,field2,field3,field4,field5
field1,field2,field3,field4,field5
field1,field2,field3,field4,field5

I know how many columns *should* be in each row (46). Basically, I think the
psudocode would be "Replace all carriage returns with spaces, unless they
are the first carriage return after the 45th field separator."

I've scoured Google for tips, but can't find much. Any help much
appreciated.

JJ