Skip to content

normalize dataset paths #107

@jheeffer

Description

@jheeffer

Path normalization was included in the original PoC but was removed at some point.

This allows user to specify dataset path in several ways:

path/to/dataset/datapackage.json
path/to/dataset/
path/to/dataset

Please return it or give reasons for removing it

	function getDatapackagePath(path) {	
		if (!path.endsWith("datapackage.json")) {
			if (!path.endsWith("/")) {
				path = path + "/";
			}
			path = path + "datapackage.json";
		}
		return path;
	}

	function getBasePath(datapackagePath) {
		const dpPathSplit = datapackagePath.split("/");
		dpPathSplit.pop();
		return dpPathSplit.join("/") + "/";
	}

	const 
		datapackagePath    = getDatapackagePath(path),
		basePath           = getBasePath(datapackagePath);

https://github.com/jheeffer/ddfcsv-reader/blob/master/ddfcsv.js#L44-L58

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions