Changes

Jump to navigation Jump to search
csvkit exemples
Line 33: Line 33:  
<code>
 
<code>
 
$ csvcut -t -c code,brands en.openfoodfacts.org.products.csv > brands.csv
 
$ csvcut -t -c code,brands en.openfoodfacts.org.products.csv > brands.csv
 +
</code>
 +
 +
''Selecting products based on a regular expression''. csvkit can search in some specified fields, allowing to make powerful selections. The following command creates a CSV file (selection.csv) containing all products where the barcode (code) is beginning by 325798 (<code>-r "^325798(.*)"</code>).
 +
 +
<code>
 +
$ csvgrep -t -c code -r "^325798(.*)" en.openfoodfacts.org.products.csv > selection.csv
 +
</code>
 +
 +
The following command creates a CSV file (calissons.csv) containing all products where the category (categories) is containing "calisson".
 +
 +
<code>
 +
$ csvgrep -t -c categories -r "calisson" en.openfoodfacts.org.products.csv > calisson.csv
 
</code>
 
</code>
  

Navigation menu