[R] re adLines fails to read entire file

Berend Hasselman bhh at xs4all.nl
Tue Jun 10 09:00:23 CEST 2008



Dennis Fisher wrote:
> 
> Colleagues
> 
> I have just encountered an interesting problem with readLines in R  
> 2.7.0 in Windows Vista.  I am trying to read a line that is created in  
> the following manner:
> 	1.  Intel Fortran (ifort) 10.1 creates two text files.
> 	2.  The OS concatenates these files with: 	copy FILE1 +FILE2 FILE3
>  From R, I execute:	readLines("FILE3")
> Only the first portion of the file (the original FILE1) is read - the  
> remainder is ignored and there is no error message.
> 
> When I open FILE3 with Notepad, it shows all the text; however,  
> between the material originating from FILE1 and FILE2, there is a  
> single character - a right-pointing arrow.  When I open the file with  
> vi in Windows (installed under ssh), it shows ^Z.  When I open the  
> file with a hex editor (after having moved the file to a Mac), it  
> shows that this character is 1A.
> 

Use the /b (binary) option of the copy command

copy /b file1+file2 file3

Then no Ctrl+Z be written to file3.
This is a known but easily forgotten irritant of the copy command in windows
and dos.

Berend Hasselman


-- 
View this message in context: http://www.nabble.com/readLines-fails-to-read-entire-file-tp17744203p17748987.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list