This should work:
a = Mmap.mmap("test.txt")
n = 1
for i in 1:length(a)
if a[i]==10
n+=1
end
end
@show n
Am 19.08.2015 um 12:13 schrieb René Donner <[email protected]>:
> I guess you could access it using mmap and simply loop through the array:
>
> http://docs.julialang.org/en/latest/stdlib/io-network/?highlight=mmap#memory-mapped-i-o
>
> I'd be curious, are there even faster alternatives?
>
>
>
> Am 19.08.2015 um 12:10 schrieb Daniel Carrera <[email protected]>:
>
>> Hello,
>>
>> I need to count the number of lines in a large number of UNIX text files,
>> most of which are fairly large. I need help coming up with an efficient
>> implementation of a line-count program. A naive implementation like
>> length(readlines("foo.txt")) is very slow (notice how this loads the whole
>> file into memory just to count newlines). I imagine that it should be
>> possible to count the number of newline characters quickly, like what the
>> "wc" command does, but I can't figure out how. Does anyone have any ideas?
>>
>> Thanks for the help.
>>
>> Daniel.
>