Follow up from Read SHP file from SFTP using pysftp for more context.
I am trying to use pyshp and pysftp to read a shapefile and convert to a GeoPandas geodataframe. This has worked successfully for all files tested until the following error occurred.
Code:
from shapely.geometry import shape
r = shapefile.Reader(shp=shp, shx=shx, dbf=dbf)
fields = [field[0] for field in r.fields[1:]]
attributes = []
geometry = []
for row in r.shapeRecords():
geometry.append(shape(row.shape.__geo_interface__))
attributes.append(dict(zip(fields, row.record)))
Error:
~\miniconda3\lib\site-packages\shapefile.py in __shape(self)
1039 record = Shape()
1040 nParts = nPoints = zmin = zmax = mmin = mmax = None
-> 1041 (recNum, recLength) = unpack(">2i", f.read(8))
1042 # Determine the start of the next record
1043 next = f.tell() + (2 * recLength)
~\miniconda3\lib\site-packages\paramiko\file.py in read(self, size)
~\miniconda3\lib\site-packages\paramiko\sftp_file.py in _read(self, size)
~\miniconda3\lib\site-packages\paramiko\sftp_client.py in _request(self, t, *arg)
~\miniconda3\lib\site-packages\paramiko\sftp_client.py in _async_request(self, fileobj, t, *arg)
~\miniconda3\lib\site-packages\paramiko\message.py in add_int64(self, n)
error: int too large to convert
Is there a way to convert this int or perform this in chunks to avoid the error? The file that caused the error is not especially large (<2MB).