Closed georgeslabreche closed 6 years ago
Actually, I will need a Resource class even if it's just for the .iter and .read methods to be invoked as they are invoked in the other libraries.
From @roll, commented on Issue #8:
@georgeslabreche
In other libs package.resources
has Resource[]
type. It's pretty common operation on data package when we iterate over resource and e.g. reading them:
for resource in package.resoures:
print(resource.read(keyed=True))
So providing here API over raw data structures is very desirable.
And for raw data structure iteration users always could do:
for resource_descriptor in package.descriptor['resoures']:
print(resource_descriptor)
Actually, I will need a Resource class even if it's just for the .iter and .read methods to be invoked as they are invoked in the other libraries.
Yes. Resource is probably the most important component in the whole eco-system because it represents a data file. I think I've mentioned it in some other issue but just in case copying it here - in other libs we're able to re-use a lot of tableschema.Table
for the Resource
class. For many operations (like reading) it's just a wrapper over tableschema.Table
.
At the moment, a Resource is simply a JSONObject and a list of Resources is a JSONArray of JSONObjects.
Something like getResources() return a JSONArray of JSONObjects representing Resource objects. This goes back to my first question in Issue #7. The reason I went ahead with JSONObjects and JSONArray is because its seems like 1) we don't necessarily want to map every single datapackage JSON elements to equivalent class and properties and 2) in the other libraries we are interacting with JSON structure directly so I thought I'd preserve that element. Nothing stops us from creating a Resource class and working with that, but where do we draw the lines as to what is represented by a class and what isn't?