# Cleaning Data

**URL:** https://discourse.julialang.org/t/cleaning-data/99015
**Category:** New to Julia
**Created:** [May 17, 2023, 7:31pm UTC](https://discourse.julialang.org/t/cleaning-data/99015 "2023-05-17T19:31:11Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![eweiss](https://avatars.discourse-cdn.com/v4/letter/e/b487fb/32.png) [@eweiss](https://discourse.julialang.org/u/eweiss)
#### Post date: [May 17, 2023, 7:31pm UTC](https://discourse.julialang.org/t/cleaning-data/99015/1 "2023-05-17T19:31:11Z")

</div>

I am downloading a CSV file that has financial data. So it has dollar signs, commas, decimal points, pluses, and minuses. I’ve been trying to remove this extra stuff so I can using floating point arithmetic, but I can’t get anywhere.

a = [“$123.00”, “$1,234.56”, “-$123.45”]

julia\> replace!(a, “,” =\> “”)  
3-element Vector{String}:  
“$123.00”  
“$1,234.56”  
“-$123.45”

The comma remains. I get the same results (no change) trying to remove the $.,- symbols. There’s got to be an easy way to handle this.

---

<div class="post-metadata">

### Author: ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)
#### Post date: [May 17, 2023, 7:34pm UTC](https://discourse.julialang.org/t/cleaning-data/99015/2 "2023-05-17T19:34:46Z")

</div>

```julia

julia> a = [raw"$123.00", raw"$1,234.56", raw"-$123.45"]
       
       parse.(Float64, replace.(a, "," => "", raw"$" =>""))
3-element Vector{Float64}:
  123.0
 1234.56
 -123.45

```

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [May 17, 2023, 7:40pm UTC](https://discourse.julialang.org/t/cleaning-data/99015/3 "2023-05-17T19:40:12Z")

</div>

> [@eweiss](#):
>
> julia\> replace!(a, “,” =\> “”)

The reason this didn’t work is because `a` doesn’t contain an element `","`.

You want to perform this `replace` for each element of `a`, not on `a` itself

---

<div class="post-metadata">

### Author: ![eweiss](https://avatars.discourse-cdn.com/v4/letter/e/b487fb/32.png) [@eweiss](https://discourse.julialang.org/u/eweiss)
#### Post date: [May 17, 2023, 8:17pm UTC](https://discourse.julialang.org/t/cleaning-data/99015/4 "2023-05-17T20:17:21Z")

</div>

Thanks. I meant to write r"," not “,”.
