frictionlessdata / datapackage-go

A Go library for working with Data Package.
MIT License
21 stars 4 forks source link

building package ZIP with data subdirectory #16

Closed fils closed 6 years ago

fils commented 6 years ago

This issue is based on code at: https://github.com/OpenCoreData/ocdGarden/tree/master/frictionlessdata/pkgBuilderStatic

given the descriptor in main.go

    descriptor := map[string]interface{}{
        "resources": []interface{}{
            map[string]interface{}{
                "name": "datatest1",
                // "path": "./data.csv",
                "path":   "./data/data.csv",
                "format": "csv",
                // "profile": "tabular-data-resource",
            },
        },
    }

The two paths ./data.csv and ./data/data.csv give different results.

I am trying to build a package.zip that has internal hierarchy

The first path works correctly, but the second gives an error. The first run below is with ./data.csv active. The second run is with ./data/data.csv being used.

fils@xps:pkgBuilderStatic$ go run main.go
Frictionless Data Package Bulder
fils@xps:pkgBuilderStatic$ unzip -l package.zip
Archive:  package.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
      203  2018-04-19 09:12   datapackage.json
      879  2018-04-19 09:12   data.csv
---------                     -------
     1082                     2 files

now run with ./data/data.csv

fils@xps:pkgBuilderStatic$ go run main.go
Frictionless Data Package Bulder
2018/04/19 09:12:51 in zip builder
2018/04/19 09:12:51 open /tmp/datapackage_zip656158799/data/data/data.csv: no such file or directory
panic: open /tmp/datapackage_zip656158799/data/data/data.csv: no such file or directory

goroutine 1 [running]:
main.main()
        /home/fils/src/go/src/opencoredata.org/ocdGarden/frictionlessdata/pkgBuilderStatic/main.go:38 +0x545
exit status 2

Curious if it's me or an issue with making packages with internal hierarchy.

danielfireman commented 6 years ago

Hi Doug, good afternoon.

You found a bug in the library! :+1:

The bug has already been fixed (added tests to make sure it does not come back) and a new release pushed. Could you please try it and let us know how it goes?

Thanks a lot!

fils commented 6 years ago

@danielfireman THANKS! looks like my simple examples are running!
I think we can close this.

FYI, I have deadline to get a set of 400 to 500 packages built here in a week or two using this package and then publish them out to a demonstration server. I'll let you know how it goes!

danielfireman commented 6 years ago

Glad to know it is working!

FYI, I have deadline to get a set of 400 to 500 packages built here in a week or two using this package and then publish them out to a demonstration server. I'll let you know how it goes!

Awesome! Yes, please let me know. Looking forward to hearing news on this side!