# Reading text data: \`readdlm\` is deprecated, so how CSV package is used?

**URL:** <https://discourse.julialang.org/t/reading-text-data-readdlm-is-deprecated-so-how-csv-package-is-used/116955>\
**Category:** General Usage\
**Tags:** question, csv, io, delimitedfiles, text-data\
**Created:** [July 12, 2024, 9:15am UTC](https://discourse.julialang.org/t/reading-text-data-readdlm-is-deprecated-so-how-csv-package-is-used/116955 "2024-07-12T09:15:11Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![ryofurue](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ryofurue/32/24531_2.png) [@ryofurue](https://discourse.julialang.org/u/ryofurue)\
**Post date:** [July 15, 2024, 6:36am UTC](https://discourse.julialang.org/t/reading-text-data-readdlm-is-deprecated-so-how-csv-package-is-used/116955/3 "2024-07-15T06:36:17Z")

</div>

> [@oheil](#):
>
> ```julia-auto
> using CSV, DataFrames
> 
> myfile = "infile.txt"
> df = CSV.read(myfile,DataFrame)
> 
> ```

Thanks! I’ve made some progress using that. But I got stuck with delimiters. According to the thread (from 2021) which I quote at the end of this message, you have to preprocess the input text file if it uses multiple delimiters. Is that still true today? I thought that it was quite usual to expect to be able to specify a Regex, along the lines of

```julia
   df = CSV.read(myfile, DataFrame; delim=r"\s+") # any sequence of "space" characters

```

so that any nonzero sequence of “space” characters ( `\s` ) be tread as one single delimiter.

Currently `CSV.read()` isn’t able to “guess” the number of columns in my datafile, presumably because the datafile uses a mixture of tabs and spaces. `readdlm()` correctly detects the delimiters.

> [@Reading data text files delimited with both spaces & tabs](https://discourse.julialang.org/t/reading-data-text-files-delimited-with-both-spaces-tabs/64851):
>
> Is it possible in CSV.jl, DelimitedFiles.jl, or other, to read text files that contain both spaces & tabs, in the header and/or data sections? An example is provided below. NB: the hidden spaces and tabs should be there after copy and paste, also added row with missing value Col1 Col2 Col3 1 1 012 2 1 013 2 1 2 1 015 Currently, the workaround used is to replace all tabs by spaces in a text editor and then read the file using CSV.jl: using CSV, DataFrames df = CSV.read(file, …

---

_[View the full topic](https://discourse.julialang.org/t/reading-text-data-readdlm-is-deprecated-so-how-csv-package-is-used/116955)._
