Re: [julia-users] Re: How to read any lines with stream open(file)

2015-06-17 Thread Seth
You can also use chomp() which is specific to newlines (strip() removes all whitespace) Base.chomp(string) Remove a trailing newline from a string julia> a = "asd " "asd " julia> chomp(a) "asd " julia> strip(a) "asd" On Wednesday, June 17, 2015 at 4:41:45 AM UTC-5, René Donner wrote: > >

Re: [julia-users] Re: How to read any lines with stream open(file)

2015-06-17 Thread René Donner
Hi, you can use strip() for that. This and some other very handy functions (e.g. lstrip / rstrip) are listed in http://docs.julialang.org/en/release-0.3/stdlib/strings/?highlight=strip#strings cheers, rene Am 17.06.2015 um 11:38 schrieb Paul Analyst : > Is another way [1:end-1] to lost "\

Re: [julia-users] Re: How to read any lines with stream open(file)

2015-06-17 Thread Paul Analyst
Is another way [1:end-1] to lost "\n" on the end of line? julia> readline(open("temp.txt"))[1:end] "1\n" julia> readline(open("temp.txt"))[1:end-1] "1" Paul W dniu 2015-06-17 o 11:33, Paul Analyst pisze: Ok, sorry, i don`t see 1 line:) |Base.readline(s, i::Int) = (for (j,line) in enumerate(eac

Re: [julia-users] Re: How to read any lines with stream open(file)

2015-06-17 Thread Paul Analyst
Ok, sorry, i don`t see 1 line:) |Base.readline(s, i::Int) = (for (j,line) in enumerate(eachline(s)); if j==i; return line; end; end; error("not enough lines")) Is oK ,big thx Paul | W dniu 2015-06-17 o 11:27, Paul Analyst pisze: Unfrtunatly can`t run, (in Julia 3.6 the same) _

Re: [julia-users] Re: How to read any lines with stream open(file)

2015-06-17 Thread Paul Analyst
Unfrtunatly can`t run, (in Julia 3.6 the same) _ _ _ _(_)_ | A fresh approach to technical computing (_) | (_) (_)| Documentation: http://docs.julialang.org _ _ _| |_ __ _ | Type "help()" for help. | | | | | | |/ _` | | | | |_| | | | (_| | |

[julia-users] Re: How to read any lines with stream open(file)

2015-06-16 Thread Tom Breloff
You could create your own: julia> Base.readline(s, i::Int) = (for (j,line) in enumerate(eachline(s)); if j==i; return line; end; end; error("not enough lines")) readline (generic function with 4 methods) julia> f = open("/tmp/tmp.txt", "w") IOStream() julia> for i in 1:20 write(f, "$i\n") end