Skip to content

Instantly share code, notes, and snippets.

@lauri-kaariainen
Created October 30, 2022 13:23
Show Gist options
  • Save lauri-kaariainen/0d46c498dbbc4f84f4c0af99e92fbfb9 to your computer and use it in GitHub Desktop.
Save lauri-kaariainen/0d46c498dbbc4f84f4c0af99e92fbfb9 to your computer and use it in GitHub Desktop.
sqlite3 line to create json list from read fineli csv
sqlite3 -json build/fineli.db "SELECT
cv.food_id,
GROUP_CONCAT(cv.value) AS Valuelist,
GROUP_CONCAT(c.description) AS Desclist,
f.name AS name
FROM component_value cv
JOIN food f ON f.id = cv.food_id
INNER JOIN components c ON c.id = cv.component_id
JOIN units u ON u.id = c.unit_id
JOIN component_class cc ON cc.id = c.component_class_id
JOIN component_class cc2 ON cc2.id = c.component_superclass_id
JOIN sources s ON s.id = cv.source_id
JOIN methods m ON m.id = cv.method_id
WHERE (c.id == 4 OR c.id == 6 OR c.id == 17 OR c.id == 37)
GROUP BY cv.food_id" > foods.json
@lauri-kaariainen
Copy link
Author

iconv -f iso-8859-1 -t utf-8 foods.json > foodsutf8.json

@lauri-kaariainen
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment