[R-sig-Geo] count how many row i have in a txt file in a directory
Rainer Hurling
rhurlin at gwdg.de
Sun Feb 26 19:46:02 CET 2012
On 26.02.2012 15:03 (UTC+1), gianni lavaredo wrote:
> Dear Researchers,
>
> I have a large TXT (X,Y,MyValue) file in a directory and I wish to import
> row by row the txt in a loop to save only the data they are inside a buffer
> (using inside.owin of spatstat) and delete the rest. The first step before
> to create a loop row-by-row is to know how many rows there are in the txt
> file without load in R to save memory problem.
If I remember right from another thread, you are on Max OSX?
If so, you could try Unix alike commands like 'wc' (word count) with
option 'l' for lines:
#as.numeric(unlist(strsplit(system("wc -l file.txt", intern=TRUE),
split=" "))[2])
I suspect, there must be other, much more elegant methods ...
Rainer
> some people know the specific function?
>
> thanks in advance for all suggestions
> Gianni
More information about the R-sig-Geo
mailing list