# How to repleace some chars in a HTTP --\> CSV --\> DataFrame workflow?

**URL:** https://discourse.julialang.org/t/how-to-repleace-some-chars-in-a-http-csv-dataframe-workflow/58232
**Category:** General Usage
**Tags:** dataframes, csv, http
**Created:** [March 30, 2021, 2:22pm UTC](https://discourse.julialang.org/t/how-to-repleace-some-chars-in-a-http-csv-dataframe-workflow/58232 "2021-03-30T14:22:25Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)
#### Post date: [March 30, 2021, 2:22pm UTC](https://discourse.julialang.org/t/how-to-repleace-some-chars-in-a-http-csv-dataframe-workflow/58232/1 "2021-03-30T14:22:25Z")

</div>

I am trying to pass a (small) CSV file to DataFrame without saving it to disk, but I need first to convert the tabs in spaces, as it is a bit “dirty”.

I have tried this but it doesn’t work:

```julia
urlData = "https://archive.ics.uci.edu/ml/machine-learning-databases/auto-mpg/auto-mpg.data-original"
data = CSV.File(replace(IOBuffer(String(HTTP.get(urlData).body)),'\t' => ' '), delim=' ',missingstring="NA", ignorerepeated=true, header=false) |> DataFrame

```

The part that is not working is the `replace` one…

---

<div class="post-metadata">

### Author: ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)
#### Post date: [March 30, 2021, 4:05pm UTC](https://discourse.julialang.org/t/how-to-repleace-some-chars-in-a-http-csv-dataframe-workflow/58232/2 "2021-03-30T16:05:28Z")

</div>

Here’s one way:

```julia
using Pipe: @pipe

urlData = "https://archive.ics.uci.edu/ml/machine-learning-databases/auto-mpg/auto-mpg.data-original"

@pipe HTTP.get(urlData).body |>
    replace!(_, UInt8('\t') => UInt8(' ')) |>
    CSV.File(_, delim=' ', missingstring="NA", ignorerepeated=true, header=false) |> 
    DataFrame

```

(I don’t think you can call `replace` on an `IOBuffer`.)

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [March 30, 2021, 4:08pm UTC](https://discourse.julialang.org/t/how-to-repleace-some-chars-in-a-http-csv-dataframe-workflow/58232/3 "2021-03-30T16:08:23Z")

</div>

It’s weird that `delim='\t'` doesn’t work. So maybe consider filing an issue.

---

<div class="post-metadata">

### Author: ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)
#### Post date: [March 30, 2021, 4:23pm UTC](https://discourse.julialang.org/t/how-to-repleace-some-chars-in-a-http-csv-dataframe-workflow/58232/4 "2021-03-30T16:23:05Z")

</div>

> [@pdeffebach](#):
>
> It’s weird that `delim='\t'` doesn’t work.

It looks like the data has space-separated columns except for the last one which is tab-separated.

---

<div class="post-metadata">

### Author: ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)
#### Post date: [March 30, 2021, 4:45pm UTC](https://discourse.julialang.org/t/how-to-repleace-some-chars-in-a-http-csv-dataframe-workflow/58232/5 "2021-03-30T16:45:36Z")

</div>

Exactly 😉

This is why I need first to replace the single tab separation column… unless CSV can now specify multiple field delimiters, but I am unaware of that…
