[R] eliminating control characters from formatted data files

2009-02-05 Thread David Epstein
I have a few hundred files of formatted data. Unfortunately most of them end with a spurious CONTROL-Z. I want to rewrite the files without the spurious character. Here's what I've come up with so far, but my code is unsafe because it assumes without justification that the last row of df contains

Re: [R] eliminating control characters from formatted data files

2009-02-05 Thread jim holtman
Here is one way of doing it. You can read it in as raw and then either replace/delete the control character and write the file back out: # read in as 'raw' and delete the control-Z from the string x - readBin('/tempyy.txt', 'raw', n=10) x [1] 54 68 69 73 20 69 73 20 61 20 74 65 73 74 20

Re: [R] eliminating control characters from formatted data files

2009-02-05 Thread Murray Cooper
49083 Mail: richs...@earthlink.net - Original Message - From: David Epstein david.epst...@warwick.ac.uk To: r-help@r-project.org Sent: Thursday, February 05, 2009 4:01 AM Subject: [R] eliminating control characters from formatted data files I have a few hundred files of formatted data

Re: [R] eliminating control characters from formatted data files

2009-02-05 Thread David Epstein
Murray Cooper wrote: This may be a case of If all you have is a hammer, everything looks like a nail. If all you want to do is remove the last line if it contains a CONTROL-Z, why not use something like perl to process the files? My first thought was to use perl, and this would have