# CSV.jl's CSV write seems slow

**URL:** <https://discourse.julialang.org/t/csv-jls-csv-write-seems-slow/7643>\
**Category:** Performance\
**Created:** [December 9, 2017, 4:21am UTC](https://discourse.julialang.org/t/csv-jls-csv-write-seems-slow/7643 "2017-12-09T04:21:47Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![y4lu](https://avatars.discourse-cdn.com/v4/letter/y/47e85d/32.png) [@y4lu](https://discourse.julialang.org/u/y4lu)\
**Post date:** [February 2, 2018, 5:40am UTC](https://discourse.julialang.org/t/csv-jls-csv-write-seems-slow/7643/12 "2018-02-02T05:40:29Z")

</div>

You may want to test this out, it’s usually pretty quick

```julia
function ch_reader(fil)
  fid = open(fil, "r");
  x = stat(fid).size;
  println("$fil chars $x");
  data = Array(Cuchar, x);
  data[:] = read(fid, Cuchar, x);
  close(fid);
  return(data);
  end;
 
  
function cleanload(fname)
  if(isfile("$(fname)"))
    passch = ch_reader("../input/$(fname)");
    else
    println("file not found!");
    return([]);
    end;
  passstr = String(passch);
  (xtrainx, xtrainh) = readdlm(IOBuffer(passstr), '\t', Any, '\n', header=true);
  println("$(size(xtrainx)) \n $xtrainh");
  return(xtrainx);
  end;

```

Or if csv is not so important and you have a fixed type

```julia
##-----------------
## speed loading with int32's

function xLoad_i32(fname)
  fid = open(fname, "r");
  x0 = read(fid, Int32, 1);
  x1 = read(fid, Int32, x0[1]);
  x2 = zeros(Int32, x1[1], x1[2]);
  x2[:] = read(fid, Int32, x1[1]*x1[2]);
  close(fid);
  return(x2);
  #xmat = reshape(x2, x1[1], x1[2]);
  end;
  
function xSave_i32(fname, mat)
  x = open(fname, "w");
  a = map(Int32, ndims(mat));
  write(x, a);
  for iter = 1:a
    b = size(mat, iter);
    write(x, map(Int32, b));
    end;
  write(x, map(Int32, mat[:]));
  close(x);
  end;

```

---

_[View the full topic](https://discourse.julialang.org/t/csv-jls-csv-write-seems-slow/7643)._
