# Writing and Reading Binary vtk file

**URL:** https://discourse.paraview.org/t/writing-and-reading-binary-vtk-file/3981
**Category:** ParaView Support
**Tags:** vtk
**Created:** [April 6, 2020, 8:22pm UTC](https://discourse.paraview.org/t/writing-and-reading-binary-vtk-file/3981 "2020-04-06T20:22:03Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![jaekwangjk12](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jaekwangjk12/32/10346_2.png) [@jaekwangjk12](https://discourse.paraview.org/u/jaekwangjk12)
#### Post date: [April 6, 2020, 8:22pm UTC](https://discourse.paraview.org/t/writing-and-reading-binary-vtk-file/3981/1 "2020-04-06T20:22:03Z")

</div>

Hi, all, I have difficulties in writing binary vtk file that can be opened paraview.  
I attach two files one is written in ASCII and paraview renders this ASCII file very well  
However, as I try to open the Binary file, I receives errors saying that

```
ERROR: In /Users/kitware/dashboards/buildbot-slave/8275bd07/build/superbuild/paraview/src/VTK/IO/Legacy/vtkPolyDataReader.cxx, line 303
vtkPolyDataReader (0x7faa29f38ea0): Unrecognized keyword:

```

Anyone has idea where I might have a mistake?

The attached files has a structure like this

```
# vtk DataFile Version 2.0
vtk output
BINARY
DATASET POLYDATA
POINTS 4 double
[[Binary Data]]......
POLYGONS 1 5
4 0 1 2 3
CELL_DATA 1
POINT_DATA 4
SCALARS nodal double
LOOKUP_TABLE default
[[Binary Data]]......

```

Thanks!

Jaekwang Kim

[ascii.vtk](https://discourse.paraview.org/uploads/short-url/r3yECpJ3NyL3bbGYDbv8VSyzHu0.vtk) (204 Bytes) [binary.vtk](https://discourse.paraview.org/uploads/short-url/7bSc42lrbQ7WOB89RXycIihON7d.vtk) (301 Bytes)

---

<div class="post-metadata">

### Author: ![wu\_ying](https://discourse.paraview.org/user_avatar/discourse.paraview.org/wu_ying/32/9035_2.png) [@wu\_ying](https://discourse.paraview.org/u/wu_ying)
#### Post date: [April 19, 2022, 11:06am UTC](https://discourse.paraview.org/t/writing-and-reading-binary-vtk-file/3981/2 "2022-04-19T11:06:30Z")

</div>

有同样的问题咨询，vtk的二进制格式是怎样的

---

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [April 19, 2022, 12:24pm UTC](https://discourse.paraview.org/t/writing-and-reading-binary-vtk-file/3981/3 "2022-04-19T12:24:59Z")

</div>

Several issues:

1. new lines in binary data for POINTS
2. POLYGONS specified in ASCII … should be binary data there too

Attached is a “fixed” version. Hope that helps.  
[binary.vtk](https://discourse.paraview.org/uploads/short-url/jhBIdEheKd13oWfeSUiblgY6s3k.vtk) (309 Bytes)

---

<div class="post-metadata">

### Author: ![silkwormbuaa](https://discourse.paraview.org/user_avatar/discourse.paraview.org/silkwormbuaa/32/10851_2.png) [@silkwormbuaa](https://discourse.paraview.org/u/silkwormbuaa)
#### Post date: [February 7, 2023, 1:10pm UTC](https://discourse.paraview.org/t/writing-and-reading-binary-vtk-file/3981/4 "2023-02-07T13:10:47Z")

</div>

Hi Utkarsh,

Thanks for your reply. May I ask how did you add new lines in binary data?
