# "Vector{NamedTuple{" type

**URL:** https://discourse.julialang.org/t/vector-namedtuple-type/76619
**Category:** New to Julia
**Created:** [February 17, 2022, 11:04am UTC](https://discourse.julialang.org/t/vector-namedtuple-type/76619 "2022-02-17T11:04:03Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![nicob](https://avatars.discourse-cdn.com/v4/letter/n/ecccb3/32.png) [@nicob](https://discourse.julialang.org/u/nicob)
#### Post date: [February 17, 2022, 11:04am UTC](https://discourse.julialang.org/t/vector-namedtuple-type/76619/1 "2022-02-17T11:04:03Z")

</div>

Using the read() function from HDF5.jil I obtain this output for `data`:

> 43466-element Vector{NamedTuple{(:H1, […]}}:  
> (H1 = 8.26600, […]),  
> (H1 = 8.26600, […]),

How can I access a field? e.g. I tried `data.H1` and `data["H1"]` and got  
`type Array has no field H1` and `invalid index: "H1" of type String`.

This is working

```julia
p = zeros(size(data))

for i in 1:size(data)[1]
   p[i] = data[i].H1
end

```

but I bet there is a clever way to do it.

I appreciate any help.

---

<div class="post-metadata">

### Author: ![jipolanco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jipolanco/32/12129_2.png) [@jipolanco](https://discourse.julialang.org/u/jipolanco)
#### Post date: [February 17, 2022, 11:08am UTC](https://discourse.julialang.org/t/vector-namedtuple-type/76619/2 "2022-02-17T11:08:44Z")

</div>

```julia
p = getproperty.(data, :H1)

```

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [February 17, 2022, 12:18pm UTC](https://discourse.julialang.org/t/vector-namedtuple-type/76619/3 "2022-02-17T12:18:21Z")

</div>

Or

```julia
p = [x.H1 for x ∈ data]

```

---

<div class="post-metadata">

### Author: ![dmbates](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmbates/32/44_2.png) [@dmbates](https://discourse.julialang.org/u/dmbates)
#### Post date: [February 17, 2022, 1:22pm UTC](https://discourse.julialang.org/t/vector-namedtuple-type/76619/4 "2022-02-17T13:22:30Z")

</div>

The result you get, a `Vector{NamedTuple}`, is in the form described as a “row table” in the [Tables.jl](https://github.com/JuliaData/Tables.jl) package. You can convert it to a “column table” and extract the `H` property as a vector with

```nohighlight
julia> using Tables

julia> xvec = columntable(x).H

```
