s-news
[Top] [All Lists]

Scanning a line for a carriage return

To: s-news@lists.biostat.wustl.edu
Subject: Scanning a line for a carriage return
From: "Walter R. Paczkowski" <dataanalytics@earthlink.net>
Date: Wed, 07 Mar 2007 21:02:35 -0500
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; d=earthlink.net; b=pUpTZGbLPBfziw9XVDOiOc5bn1GD6lUcWPVyMtdcX1VxjUxoZkGBxMVPAzfuKQbn; h=Received:X-Mailer:Date:To:From:Subject:Mime-Version:Content-Type:Message-ID:X-ELNK-Trace:X-Originating-IP;
Hi,

I'm hoping someone has a suggestion for handling a simple problem.  A client gave me a comma separated value file (call it x.csv) that has an id and name and address for about 25,000 people (25,000 records).  I used read.table to read it, but then discovered that there are stray carriage returns on several records.  This plays havoc with read.table since it starts a new input line when it sees the carriage return.  In short, the read is all wrong.

I thought I could write a simple function to parse a line and write it back out, character by character.  If a carriage return is found, it would simply be ignored on the writing back out part.  But how do I identify a carriage return?  What is the code or symbol?  Is there any easier way to rid the file of carriage returns in the middle of the input lines?

Any help is appreciated.

Walt Paczkowski

_________________________________

Walter R. Paczkowski, Ph.D.
Data Analytics Corp.
44 Hamilton Lane
Plainsboro, NJ  08536
(V) 609-936-8999
(F) 609-936-3733

<Prev in Thread] Current Thread [Next in Thread>