Re: [R] handling nulls while reading mainframe file

2010-05-05 Thread Michael Steven Rooney
Thanks. Once I have my cleaned up raw vector, I need to convert to characters using the ebcdic code page. I could first convert it to characters using rawToChar() (which will give me garbled ascii), and then convert that to ebcdic using iconv(). If anyone knows of a more direct solution, let me kno

Re: [R] handling nulls while reading mainframe file

2010-05-05 Thread jim holtman
Try using readBin and 'raw' x <- readBin('yourFile', 'raw', n=1e6) You can then scan 'x' and replace NULLs (I assume they are 0x00) with whatever you want. > str(x) raw [1:10] 00 00 22 00 ... > x [1] 00 00 22 00 00 00 00 00 00 00 > x[x == as.raw(0)] <- as.raw(0xab) > x [1] ab ab 22 ab ab ab a

[R] handling nulls while reading mainframe file

2010-05-05 Thread Michael Steven Rooney
Hi, I am trying to read in records from an old main frame file. Each record is 640 bytes. I had some success using the following statement: iconv(readChar(con, nchars=640, useBytes = TRUE),from="IBM037",to="",sub="#") What I have found, however, is that ocassionally a record will contain a Null