Table Of Contents
Table Of Contents

FAQ

  1. Fields in shapefiles
  2. How to avoid entering the credentials everytime?

Fields in shapefiles

The following codes is usually used to retrieve shapefiles:

rshp = shapefile.Reader(filename)
shapes = rshp.shapes()
records = rshp.records()

records contains metadata about each shape. Fields and values are not stored in a dictionary. Here is a snippet of code to do so:

{k[0]: v for k, v in zip(rshp.fields[1:], records[0])}

Here is an example of the results:

{'ORD_PRE_DI': 'SW',
'ORD_STNAME': 'SW 149TH ST',
'ORD_STREET': '149TH',
'ORD_STRE_1': 'ST',
'ORD_SUF_DI': b'  ',
'R_ADRS_FRO': 976,
...

( : data_geo_streets.py:docstring of ensae_projects.datainc.data_geo_streets.shapely_records, line 7)

How to avoid entering the credentials everytime?

Using clear credentials in a program file or in a notebook is dangerous. You should do that. However, it is annoying to type his password every time it is required. The solution is to store it with keyring. You need to execute only once:

keyring.set_password("k1", "k2", "value")

And you can retrieve the password anytime not necessarily in the same program:

keyring.set_password("k1", "k2", "value")

( : credentials_helper.py:docstring of ensae_projects.automation.credentials_helper.set_password, line 7)