Example #1
0
def _from_dataframe(row: Series, na: Union[Any, List[Any]],
                    nesting: str) -> Resource:
    new_na = row.replace(na, np.nan)
    no_na = new_na.dropna()
    items = list(no_na.items())
    data = deflatten(items, nesting)
    return from_json(data, None)
Example #2
0
 def _map_one(self, data: Union[Path, Dict], mappings: List[Mapping],
              nas: List[Any]) -> List[Resource]:
     variables = {
         "forge": self.forge,
         "x": self._load_one(data),
     }
     mapped = (_apply_rules(x.rules, variables) for x in mappings)
     return [from_json(x, nas) for x in mapped]
Example #3
0
def _to_resource(record: Dict) -> Resource:
    # TODO This operation might be abstracted in core when other stores will be implemented.
    resource = from_json(record["data"], None)
    resource._store_metadata = wrap_dict(record["metadata"])
    resource._synchronized = True
    return resource
Example #4
0
 def from_json(self, data: Union[Dict, List[Dict]], na: Union[Any, List[Any]] = None
               ) -> Union[Resource, List[Resource]]:
     return from_json(data, na)