def get_prefix_from_xpath(xpath):
    xpath = str(xpath)
    parts = xpath.rsplit('/', 1)
    if len(parts) == 1:
        return None
    elif len(parts) == 2:
        return '%s/' % parts[0]
    else:
        raise ValueError(
            '%s cannot be prefixed, it returns %s' % (xpath, str(parts)))
dataset/ETHPy150Open kobotoolbox/kobocat/onadata/apps/viewer/pandas_mongo_bridge.py/get_prefix_from_xpath/original