# How do I avoid subtypes when building a type lookup for parsing?

**URL:** <https://discourse.julialang.org/t/how-do-i-avoid-subtypes-when-building-a-type-lookup-for-parsing/80198>\
**Category:** General Usage\
**Tags:** type, parsing\
**Created:** [April 28, 2022, 10:07am UTC](https://discourse.julialang.org/t/how-do-i-avoid-subtypes-when-building-a-type-lookup-for-parsing/80198 "2022-04-28T10:07:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![feanor12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/feanor12/32/8212_2.png) [@feanor12](https://discourse.julialang.org/u/feanor12)\
**Post date:** [April 28, 2022, 10:07am UTC](https://discourse.julialang.org/t/how-do-i-avoid-subtypes-when-building-a-type-lookup-for-parsing/80198/1 "2022-04-28T10:07:41Z")

</div>

I read in a csv file and I want to generate types based on the content.  
My idea was to build a lookup dictionary for this, however the `subtypes` function only exists in InteractiveUtils.jl. I would like to avoid including this in my package.

How do I avoid using subtypes to build a save translation of string/symbols to types.

The current code looks like this:

```julia
function build_lookup_dict(abstract_type)
    types = subtypes(abstract_type)
    return Dict(nameof.(types) .=> types)
end

abstract type myabstracttype end
struct mytype1 <: myabstracttype end
struct mytype2 <: myabstracttype end

#----------

julia> input = " mytype1"
" mytype1"

julia> dict = build_lookup_dict(myabstracttype)
Dict{Symbol, DataType} with 2 entries:
  :mytype1 => mytype1
  :mytype2 => mytype2

julia> dict[Symbol.(strip(input))]
mytype1

```
