# CSV.jl open file error, contain data in scientific notation format

**URL:** <https://discourse.julialang.org/t/csv-jl-open-file-error-contain-data-in-scientific-notation-format/10694>\
**Category:** General Usage\
**Tags:** dataframes, csv\
**Created:** [May 4, 2018, 6:33am UTC](https://discourse.julialang.org/t/csv-jl-open-file-error-contain-data-in-scientific-notation-format/10694 "2018-05-04T06:33:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhangliye](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zhangliye/32/3208_2.png) [@zhangliye](https://discourse.julialang.org/u/zhangliye)\
**Post date:** [May 4, 2018, 6:33am UTC](https://discourse.julialang.org/t/csv-jl-open-file-error-contain-data-in-scientific-notation-format/10694/1 "2018-05-04T06:33:58Z")

</div>

When I open the CSV file containing integer file in the scientific notation format, such as `2e2` for the integer 200. When I use CSV.jl to open this file, I got the following error.

> CSV.ParsingException(“error parsing a `Int64` value on column 2, row 7190; encountered ‘e’”)

> CSV file data table as f as  
> x, y  
> 12, 567e3  
> 18, 2356

The Julia code is

```julia
using CSV
dtype = Type[Union{Missing,Int64} for i=1:2];
df_ais = CSV.read( file_path; delim=",", datarow=2, header=["x", "y"], types=dtype )

```

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [May 4, 2018, 8:25am UTC](https://discourse.julialang.org/t/csv-jl-open-file-error-contain-data-in-scientific-notation-format/10694/2 "2018-05-04T08:25:46Z")

</div>

That’s because the type of 2e2 is a float not an integer:

```julia
julia> typeof(2e2)
Float64

```

---

<div class="post-metadata">

**Author:** ![zhangliye](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zhangliye/32/3208_2.png) [@zhangliye](https://discourse.julialang.org/u/zhangliye)\
**Post date:** [May 4, 2018, 8:31am UTC](https://discourse.julialang.org/t/csv-jl-open-file-error-contain-data-in-scientific-notation-format/10694/3 "2018-05-04T08:31:09Z")

</div>

Thank you so much! It works.

---

<div class="post-metadata">

**Author:** ![traktofon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/traktofon/32/591_2.png) [@traktofon](https://discourse.julialang.org/u/traktofon)\
**Post date:** [May 4, 2018, 10:14am UTC](https://discourse.julialang.org/t/csv-jl-open-file-error-contain-data-in-scientific-notation-format/10694/4 "2018-05-04T10:14:45Z")

</div>

While the Julia type of `2e2` and `567e3` is `Float64`, they can be cleanly converted to `Int64`. In the interest of “being liberal in what you accept”, maybe CSV.jl should attempt to do a conversion? After all, the CSV file might come from an application that does not adhere to Julia semantics.

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [May 4, 2018, 10:52am UTC](https://discourse.julialang.org/t/csv-jl-open-file-error-contain-data-in-scientific-notation-format/10694/5 "2018-05-04T10:52:43Z")

</div>

Yea, I’ve come across situations where I wanted a round `Float64` to magically become an `Int`, but this behavior would be outside the scope of `CSV` and downright unexpected: in my (albeit limited) experience, number notations with the exponential `e` (e.g. 2e2) are always treated as floats.  
Part of the problem is that if we treat such numbers as `Int`s where we can, then their type won’t be guaranteed, it would depend on their value. But that issue doesn’t have to do with `CSV`, it’s a separate discussion.  
BTW, I think there is a package that automatically converts floats to integers when it can, but I forgot what it’s called…
