| To: | "Walter R. Paczkowski" <dataanalytics@earthlink.net> |
|---|---|
| Subject: | Re: Scanning a line for a carriage return |
| From: | "Andreas Krause" <akrause@Pharsight.com> |
| Date: | Fri, 9 Mar 2007 03:37:48 -0800 |
| Cc: | <s-news@lists.biostat.wustl.edu> |
| Thread-index: | AcdhJbE1v+fK4swRRR6LhWHJDCNykQBGKFXg |
| Thread-topic: | [S] Scanning a line for a carriage return |
|
Hi,
the easy way out is to get rid of the carriage
returns.
Under most unix distributions, you would have a tool like
dos2unix.
(Note: do you want the Ctrl-Ms to insert a new line or not?
dos2unix adds new lines)
Under Windows, wordpad is generally better than
notepad in handling CR characters (Ctrl-M).
You should be able to just open the file with wordpad,
ctrl-a to select all, ctrl-c for copy, and paste into a new
document.
Many editors can also do the job in that you can specify
what type of file to save (DOS, Unix) or get rid of the characters (see emacs or
vi).
Does this help?
Alternatively, see if importData instead of read.table does
the job.
Andreas Krause
-----
Andreas Krause, PhD Pharsight Corporation Strategic Consulting Services http://www.pharsight.com/ Phone: +41-61-481 39 74 Fax: +41-61-481 39 78 Cell: +41-76-324 75 54 From: s-news-owner@lists.biostat.wustl.edu [mailto:s-news-owner@lists.biostat.wustl.edu] On Behalf Of Walter R. Paczkowski Sent: Thursday, March 08, 2007 3:03 AM To: s-news@lists.biostat.wustl.edu Subject: [S] Scanning a line for a carriage return 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> |
|---|---|---|
| ||
| Previous by Date: | Interpreting main effects and interactions in lme (and log reg) models, Lise Hedevang Nielsen |
|---|---|
| Next by Date: | Re: Scanning a line for a carriage return, J. S. Gangolly |
| Previous by Thread: | Scanning a line for a carriage return, Walter R. Paczkowski |
| Next by Thread: | Re: Scanning a line for a carriage return, J. S. Gangolly |
| Indexes: | [Date] [Thread] [Top] [All Lists] |