# Rounding when reading in decimals from CSV

**URL:** <https://discourse.julialang.org/t/rounding-when-reading-in-decimals-from-csv/25308>\
**Category:** New to Julia\
**Created:** [June 14, 2019, 2:27pm UTC](https://discourse.julialang.org/t/rounding-when-reading-in-decimals-from-csv/25308 "2019-06-14T14:27:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![stu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stu/32/8772_2.png) [@stu](https://discourse.julialang.org/u/stu)\
**Post date:** [June 14, 2019, 2:27pm UTC](https://discourse.julialang.org/t/rounding-when-reading-in-decimals-from-csv/25308/1 "2019-06-14T14:27:24Z")

</div>

Is there a way to prevent the data from being rounded after a certain number of decimal points when reading it in from a CSV?

---

<div class="post-metadata">

**Author:** ![quinnj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/quinnj/32/11_2.png) [@quinnj](https://discourse.julialang.org/u/quinnj)\
**Post date:** [June 14, 2019, 2:38pm UTC](https://discourse.julialang.org/t/rounding-when-reading-in-decimals-from-csv/25308/2 "2019-06-14T14:38:22Z")

</div>

Can you provide an example? It should read up to Float64 precision by default.

---

<div class="post-metadata">

**Author:** ![stu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stu/32/8772_2.png) [@stu](https://discourse.julialang.org/u/stu)\
**Post date:** [June 14, 2019, 2:53pm UTC](https://discourse.julialang.org/t/rounding-when-reading-in-decimals-from-csv/25308/4 "2019-06-14T14:53:33Z")

</div>

Code:  
using CSV

nums = CSV.read(“decimal.csv”)

println(nums[2,3])

CSV looks like:  
(ignore all the trailing zeros, I just wanted to make sure that all decimal points where shown)

| | | nums |
| --- | --- | --- |
| | | -5.82697322900000000000 |
| | | 16.02264331528420000000 |
| | | 9.29517069756561000000 |
| | | 16.00004654816710000000 |
| | | 221.89095825131400000000 |
| | | 12.71430601365250000000 |
| | | 14.03442272559130000000 |
| | | 4.51014969063621000000 |
| | | 4.28867745292715000000 |
| | | 68.47032628356390000000 |
| | | 93.08060065480470000000 |
| | | 3.76030285138141000000 |
| | | 3.92982841628694000000 |
| | | 6.65743838672069000000 |
| | | 5.84854811215371000000 |
| | | 44.46672462925400000000 |
| | | 66.64378702065490000000 |
| | | 74.60975020120990000000 |
| | | 529.38862193990600000000 |

---

<div class="post-metadata">

**Author:** ![stu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stu/32/8772_2.png) [@stu](https://discourse.julialang.org/u/stu)\
**Post date:** [June 14, 2019, 4:00pm UTC](https://discourse.julialang.org/t/rounding-when-reading-in-decimals-from-csv/25308/5 "2019-06-14T16:00:56Z")

</div>

Responded below, made error in initial response

---

<div class="post-metadata">

**Author:** ![quinnj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/quinnj/32/11_2.png) [@quinnj](https://discourse.julialang.org/u/quinnj)\
**Post date:** [June 14, 2019, 4:25pm UTC](https://discourse.julialang.org/t/rounding-when-reading-in-decimals-from-csv/25308/6 "2019-06-14T16:25:23Z")

</div>

> [@stu](#):
>
> -5.82697322900000000000  
> 16.02264331528420000000  
> 9.29517069756561000000  
> 16.00004654816710000000  
> 221.89095825131400000000  
> 12.71430601365250000000  
> 14.03442272559130000000  
> 4.51014969063621000000  
> 4.28867745292715000000  
> 68.47032628356390000000  
> 93.08060065480470000000  
> 3.76030285138141000000  
> 3.92982841628694000000  
> 6.65743838672069000000  
> 5.84854811215371000000  
> 44.46672462925400000000  
> 66.64378702065490000000  
> 74.60975020120990000000  
> 529.38862193990600000000

So what exactly is the issue you’re seeing? Note that by default, the DataFrame output will show the “short” representation of Float64s, so maybe it just _ **seems** _ like there’s a rounding problem? For example:

```julia
julia> df = CSV.read("/Users/jacobquinn/Downloads/decimals.csv")
19×1 DataFrames.DataFrame
│ Row │ csv │
│ │ Float64 │
├─────┼──────────┤
│ 1 │ -5.82697 │
│ 2 │ 16.0226 │
│ 3 │ 9.29517 │
│ 4 │ 16.0 │
│ 5 │ 221.891 │
│ 6 │ 12.7143 │
│ 7 │ 14.0344 │
│ 8 │ 4.51015 │
│ 9 │ 4.28868 │
│ 10 │ 68.4703 │
│ 11 │ 93.0806 │
│ 12 │ 3.7603 │
│ 13 │ 3.92983 │
│ 14 │ 6.65744 │
│ 15 │ 5.84855 │
│ 16 │ 44.4667 │
│ 17 │ 66.6438 │
│ 18 │ 74.6098 │
│ 19 │ 529.389 │

julia> df[1]
19-element CSV.Column{Float64,Float64}:
  -5.826973229
  16.0226433152842
   9.29517069756561
  16.0000465481671
 221.890958251314
  12.7143060136525
  14.0344227255913
   4.51014969063621
   4.28867745292715
  68.4703262835639
  93.0806006548047
   3.76030285138141
   3.92982841628694
   6.65743838672069
   5.84854811215371
  44.466724629254
  66.6437870206549
  74.6097502012099
 529.388621939906

```

Notice how looking at the raw Array values show the full precision of the Float64s.
