Jump to content

Reusing Open Food Facts Data: Difference between revisions

Add examples with zcat
m (Uncompressed size)
(Add examples with zcat)
Line 91: Line 91:
  $ cat small.jsonl | jq -r .code # print all products' codes.
  $ cat small.jsonl | jq -r .code # print all products' codes.


  $ cat small.jsonl | jq -r '[.code,.product_name] | @csv' # output a CSV file containing code,product_name
  $ cat small.jsonl | jq -r '[.code,.product_name] | @csv' # output CSV data containing code,product_name
 
Then you can try on the whole database:
$ cat openfoodfacts-products.jsonl | jq -r '[.code,.product_name] | @csv' > names.csv # output CSV file (name.csv) containing all products with code,product_name
 
If you don't have enough disk place to uncompress the .gz file, you can use zcat directly on the compressed file. Example:
$ zcat openfoodfacts-products.jsonl.gz | jq -r '[.code,.product_name] | @csv' # output CSV data containing code,product_name