catatom2osm.csvtools module

CSV related help functions.

catatom2osm.csvtools.csv2dict(csv_path, a_dict=None, exists=False, single=True)[source]

Read a dictionary from a csv file.

catatom2osm.csvtools.dict2csv(csv_path, a_dict, sort=None)[source]

Write a dictionary to a csv file.

Optinally sorted by key (sort=0) or value (sort=1)

catatom2osm.csvtools.filter(csv_path, *args, query=<function <lambda>>, stop=False)[source]

Return csv rows filtered using query.

Parameters
  • args – aditional arguments for query function

  • query (func) – function with args row and wargs that returns a boolean deciding if each row will be included or not

  • stop (bool) – Stop at first match or get all

catatom2osm.csvtools.get_key(csv_path, key)[source]

Get a row given first column value.

catatom2osm.csvtools.search(csv_path, *args, query=<function <lambda>>)[source]

Return first matched row in csv.

Parameters
  • args – aditional arguments for query function

  • query (func) – function with args row and wargs that returns a boolean deciding if each row will be included or not

catatom2osm.csvtools.startswith(csv_path, key)[source]

Get rows which first column starts with key.