Changes
Jump to navigation
Jump to search
← Older edit
Newer edit →
Reusing Open Food Facts Data
(view source)
Revision as of 09:26, 8 March 2021
505 bytes added
,
09:26, 8 March 2021
Add JSONL filtering example
Line 107:
Line 107:
If you don't have enough disk space to uncompress the .gz file, you can use zcat directly on the compressed file. Example:
If you don't have enough disk space 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
$ zcat openfoodfacts-products.jsonl.gz | jq -r '[.code,.product_name] | @csv' # output CSV data containing code,product_name
+
+
==== Filtering JSONL export with jq ====
+
Filtering a specific country:
+
$ zcat openfoodfacts-products.jsonl.gz | jq '. | select(.countries_tags[]? == "en:germany")'
+
+
The previous command produces a json output containing all the products sold in Germany. If you want a JSONL output, add -c parameter.
+
$ zcat openfoodfacts-products.jsonl.gz | jq -c '. | select(.countries_tags[]? == "en:germany")'
+
+
These operations can be quite long (more than 10 minutes depending on your computer and your selection).
Charlesnepote
Bureaucrats
,
Administrators
979
edits
Navigation menu
Personal tools
English
Log in
Namespaces
Page
Discussion
Variants
Views
Read
View source
View history
More
Search
Navigation
Log in
Open Food Facts galaxy
📍Where am I?
🍊Open Food Facts website
Open Food Facts wiki
Main page
Recent changes
Random page
🧴 Open Beauty Facts wiki
Main page
Deep dive per topic
All topics
Whole wiki
Help about MediaWiki
Icons in the wiki
Tools
Special pages
Printable version
Admins
Edit sidebar
Styling
Replace text
Special Pages