# Reading complex text files with vectors

**URL:** <https://discourse.julialang.org/t/reading-complex-text-files-with-vectors/66954>\
**Category:** General Usage\
**Tags:** question, io\
**Created:** [August 25, 2021, 3:11am UTC](https://discourse.julialang.org/t/reading-complex-text-files-with-vectors/66954 "2021-08-25T03:11:42Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [August 25, 2021, 12:20pm UTC](https://discourse.julialang.org/t/reading-complex-text-files-with-vectors/66954/6 "2021-08-25T12:20:24Z")

</div>

@scone, in case it helps find a simple file reader below where input file has no headers/comments:

```julia
function readprobes(file::String, nprobes)
    data = Matrix{Array{Float64}}(undef,0,nprobes+1)
    open(file) do io
        while !eof(io)
            str = strip.(split(readline(io), ('(',')')))
            str = str[.!isempty.(str)] # removes empty elements
            v = []
            for i in 1:nprobes+1
                push!(v, parse.(Float64, split(str[i])))
            end
            data = vcat(data, permutedims(v))
        end
    end
    return data
end

file = raw"C:\..\filename.txt"

a = readprobes(file, 2) # 2 probes

3×3 Matrix{Any}:
 [0.00169492] [-5.1232, 0.0564446, 0.247042] [-5.18167, -0.00174035, 0.000190403]
 [0.00171544] [-5.14262, 0.0563817, 0.224384] [-5.20786, -0.00201589, 0.000326714]
 [0.001736] [-5.13383, 0.0565595, 0.203093] [-5.20464, -0.00220899, 0.000447314]

```

---

_[View the full topic](https://discourse.julialang.org/t/reading-complex-text-files-with-vectors/66954)._
