# Reading and interpreting math in text file

**URL:** <https://discourse.julialang.org/t/reading-and-interpreting-math-in-text-file/62320>\
**Category:** General Usage\
**Created:** [June 3, 2021, 6:42am UTC](https://discourse.julialang.org/t/reading-and-interpreting-math-in-text-file/62320 "2021-06-03T06:42:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marc\_Sevaux](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marc_sevaux/32/14986_2.png) [@Marc\_Sevaux](https://discourse.julialang.org/u/Marc_Sevaux)\
**Post date:** [June 3, 2021, 6:42am UTC](https://discourse.julialang.org/t/reading-and-interpreting-math-in-text-file/62320/1 "2021-06-03T06:42:37Z")

</div>

Hi all,  
I have a text file containing data like :

```julia
2.2*cos(pi*25/16), 2.2*sin(pi*25/16)
2.2*cos(pi*23/16), 2.2*sin(pi*23/16)
2.2*cos(pi*7/16) , 2.2*sin(pi*7/16)
...

```

I would like to read these data and store them as numbers (means interpreting them while reading) not as text.  
Any way of doing this easily?

---

<div class="post-metadata">

**Author:** ![EvoArt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evoart/32/25357_2.png) [@EvoArt](https://discourse.julialang.org/u/EvoArt)\
**Post date:** [June 3, 2021, 6:55am UTC](https://discourse.julialang.org/t/reading-and-interpreting-math-in-text-file/62320/2 "2021-06-03T06:55:23Z")

</div>

Not something I’ve done. But [parse](https://docs.julialang.org/en/v1/base/base/#Base.Meta.parse-Tuple%7BAbstractString%7D) seems to be the direction to go in

---

<div class="post-metadata">

**Author:** ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)\
**Post date:** [June 3, 2021, 6:58am UTC](https://discourse.julialang.org/t/reading-and-interpreting-math-in-text-file/62320/3 "2021-06-03T06:58:22Z")

</div>

In the REPL

julia\> eval(Meta.parse(“2.2_cos(pi_25/16)”))  
0.4291987084354823

I guess I would use CSV.jl to read the lines then parse the expressions like that?

---

<div class="post-metadata">

**Author:** ![Marc\_Sevaux](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marc_sevaux/32/14986_2.png) [@Marc\_Sevaux](https://discourse.julialang.org/u/Marc_Sevaux)\
**Post date:** [June 3, 2021, 8:44am UTC](https://discourse.julialang.org/t/reading-and-interpreting-math-in-text-file/62320/4 "2021-06-03T08:44:37Z")

</div>

Great, it works perfectly. Thanks 👌
