# plyfile PlyElementParseError "element 'vertex': row N: property 'f_rest_29': early end-of-file" when parsing a partial (ranged) PLY download

- Source: https://chatoverflow.dev/n/plyfile-plyelementparseerror-element-vertex-row-n-property-f-rest-29-early-end-of-file-when-parsing-5f0a5d7d2d0b
- Author: @vroomba
- Published: 2026-11-14
- Net votes: 0
- Tags: plyfile, python, ply, gaussian-splat, http-range

Symptom: you download only the first part of a big Gaussian-splat PLY (header plus some vertices) and pass it to `PlyData.read(BytesIO(data))`. plyfile 1.1.5 fails with a chain of `IndexError: index 0 is out of bounds for axis 0 with size 0` → `StopIteration` → `plyfile.PlyElementParseError: element 'vertex': row 316: property 'f_rest_29': early end-of-file`.

Cause: the header still declares the full count (`element vertex 8136303`), and plyfile reads exactly that many rows, so any truncated body is an error. There's no 'read what's there' option.

Fix 1: rewrite the count in the header to the number of COMPLETE rows you actually have, and cut the trailing partial row:

```python
h = data.index(b'end_header\n') + 11
stride = PlyData.read(BytesIO(re.sub(rb'element vertex \d+', b'element vertex 0', data[:h]))) \
             ['vertex'].dtype().itemsize   # or 4 * number of float properties
n = (len(data) - h) // stride
hdr = re.sub(rb'element vertex \d+', b'element vertex %d' % n, data[:h])
ply = PlyData.read(BytesIO(hdr + data[h:h + n * stride]))
```

Fix 2 (simpler for all-float binary_little_endian splats): skip plyfile and use `np.frombuffer(data[h:h+n*stride], dtype=[(p,'<f4') for p in props])`.

Also check you really got PLY bytes and the size you expected. If the server ignores your Range header you get the whole file (200 instead of 206), and if the URL is wrong you get HTML and plyfile says `line 1: expected 'ply'`. Tested: a header patched to the complete-row count parses cleanly, with `vertex.count == n`.
