# Should readdlm have a default typed value?

**URL:** <https://discourse.julialang.org/t/should-readdlm-have-a-default-typed-value/43128>\
**Category:** General Usage\
**Created:** [July 15, 2020, 1:19pm UTC](https://discourse.julialang.org/t/should-readdlm-have-a-default-typed-value/43128 "2020-07-15T13:19:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmg.duarte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmg.duarte/32/16392_2.png) [@jmg.duarte](https://discourse.julialang.org/u/jmg.duarte)\
**Post date:** [July 15, 2020, 1:19pm UTC](https://discourse.julialang.org/t/should-readdlm-have-a-default-typed-value/43128/1 "2020-07-15T13:19:44Z")

</div>

Hello everyone!

I’m currently developing a project which requires reading old text files, Fortran formated arrays. Which means I have huge text files like this:

```julia
    0.0071435 0.00745535 0.00776577 0.00807047 0.00803566 0.00798893
   0.00807762 0.00816631 0.00815916 0.00814819 0.00828075 0.00845718
   0.00815868 0.00800419 0.00791979 0.00787973 0.00795364 0.00802708

```

Using `readdlm` makes it a breeze! However, my last line is incomplete, having only 3 columns.  
Hence the output of `readdlm` is `554×6 Array{Any,2}` and if I set the type to `Float64` it errors out since `""` cannot be converted to `Float64`.

Wouldn’t it make sense for an optional default value to be specified? Like:

```julia
readdlm(source, delim::AbstractChar, T::Type, eol::AbstractChar; default::T, <omitted for brevity>)

```

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [July 15, 2020, 1:38pm UTC](https://discourse.julialang.org/t/should-readdlm-have-a-default-typed-value/43128/2 "2020-07-15T13:38:46Z")

</div>

While delimited formats are not strictly specified, columns ending prematurely is probably outside of what most users would consider a valid file. I think it is a good strategy to error for invalid data.

I would recommend that you just code a custom solution for this use case, eg read the file line by line, split the lines, and parse the floats, ending up with a vector of vectors.

---

<div class="post-metadata">

**Author:** ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Post date:** [July 15, 2020, 1:57pm UTC](https://discourse.julialang.org/t/should-readdlm-have-a-default-typed-value/43128/3 "2020-07-15T13:57:10Z")

</div>

In my opinion, this is either a bug or incorrectly documented. The docstring of `readdlm` tells:

> [@](#):
>
> If `T` is a numeric type, the result is an array of that type, with any non-numeric elements as `NaN` for floating-point types, or zero. Other useful values of `T` include `String` , `AbstractString` , and `Any` .

If instead of an empty cell the file contains the string `NaN` (case insensitive), this is true, but if there is any other non-numeric element it does not take it as `NaN`, but throws an error.
