# slow read file

**URL:** https://discourse.vtk.org/t/slow-read-file/15484
**Category:** Support
**Created:** [April 9, 2025, 2:58pm UTC](https://discourse.vtk.org/t/slow-read-file/15484 "2025-04-09T14:58:32Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![damien-mattei](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/d/45deac/32.png) [@damien-mattei](https://discourse.vtk.org/u/damien-mattei)
#### Post date: [April 9, 2025, 2:58pm UTC](https://discourse.vtk.org/t/slow-read-file/15484/1 "2025-04-09T14:58:33Z")

</div>

Hi,

when reading a 6Gb binary file (only header is text) it takes approx 98 seconds which seems slow withis code:

```auto
if data_structure == 'STRUCTURED_POINTS': reader = vtk.vtkStructuredPointsReader() # here you can add other readers in case
  
    t0 = time.time()
    reader.SetFileName(os.path.join(self.address,tar_file+'.vtk'))
    t1 = time.time()
    print('DEBUG: SetFileName',t1-t0)
    reader.ReadAllVectorsOn()
    t2 = time.time()
    print('DEBUG: ReadAllVectors v2 (Vector)',t2-t1)
    reader.Update() # un peu lent
    t3 = time.time()
    print('DEBUG: Update',t3-t2)

```

output:

```auto
DEBUG: SetFileName 5.9604644775390625e-06
DEBUG: ReadAllVectors v2 (Vector) 7.867813110351562e-06
DEBUG: Update 98.01152896881104
DEBUG: GetOutput 0.0011713504791259766

```

is it normal?  
is there a way to speed up that?

opening the file in Emacs or Vim take approx. 1 minutes,copying it 15 seconds…

regards,

Damien

---

<div class="post-metadata">

### Author: ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)
#### Post date: [April 9, 2025, 3:54pm UTC](https://discourse.vtk.org/t/slow-read-file/15484/2 "2025-04-09T15:54:21Z")

</div>

It’s called a legacy file format for a reason :-). I suggest you use the appropriate XML readers to start (vtkXMLImageDataReader). There are probably other image data readers as well that may be faster / better suit your application needs.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [April 10, 2025, 7:19am UTC](https://discourse.vtk.org/t/slow-read-file/15484/3 "2025-04-10T07:19:34Z")

</div>

Or you can also use VTKHDF format: [VTK File Formats - VTK documentation](https://docs.vtk.org/en/latest/design_documents/VTKFileFormats.html#vtkhdf-file-format)

---

<div class="post-metadata">

### Author: ![damien-mattei](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/d/45deac/32.png) [@damien-mattei](https://discourse.vtk.org/u/damien-mattei)
#### Post date: [April 17, 2025, 2:40pm UTC](https://discourse.vtk.org/t/slow-read-file/15484/4 "2025-04-17T14:40:44Z")

</div>

Rewriting in Python and NumPy my own reader for Binary VTK files containing Point3D and Vectors i moved from 98 seconds to 2.75 seconds.
