Skip to content

Commit

Permalink
Add "recipe_normal" delimiter to CSV conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinta893 committed Oct 28, 2018
1 parent 2592461 commit 68aae0d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 7 additions & 2 deletions editor/toCSV.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ for (var i = 0 ; i < recipesList.length ; i++){
//===============================================
// turns the recipe database into a csv

var headerRow = "id,name,type,wiki_link,category,time,yield,ingredients";
var headerRow = "id,name,type,wiki_link,category,recipe_normal,time,yield,ingredients...";



Expand All @@ -33,7 +33,12 @@ for (var i = 0 ; i < recipesList.length ; i++){
recipesList[i].name + "," +
recipesList[i].type + "," +
recipesList[i].wiki_link + "," +
recipesList[i].category + "," +
recipesList[i].category



//add the normal recipe
row += "," + "recipe_normal" + "," +
recipesList[i].recipe.time + "," +
recipesList[i].recipe["yield"];

Expand Down
9 changes: 5 additions & 4 deletions editor/toJSON.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ for (var i = 1 ; i < csvRows.length ; i++){ //note: skip the first as it is the

if (rowSplit.length >= 5){
//entry is greater than 5 columns, has a recipe, otherwise leave blank
recipeItem.recipe.time = parseFloat(rowSplit[5]);
recipeItem.recipe["yield"] = parseFloat(rowSplit[6]);
//recipeItem.recipeType = rowSplit[5]; //the delimiter for a normal recipe list
recipeItem.recipe.time = parseFloat(rowSplit[6]);
recipeItem.recipe["yield"] = parseFloat(rowSplit[7]);

//the rest of the row is ingredients, turn into list
recipeItem.recipe.ingredients = [];
for (var j = 7 ; j < rowSplit.length ; j++){
for (var j = 8 ; j < rowSplit.length ; j++){
if (rowSplit[j].split(":").length !=2){
continue;
}
Expand Down Expand Up @@ -61,7 +62,7 @@ for (var i = 1 ; i < csvRows.length ; i++){ //note: skip the first as it is the
//===============================================
// output to file


console.log("Total recipes parsed: " + jsonList.length);
writeToFile("recipes_csv_converted.json", JSON.stringify(jsonList, null, 4));


Expand Down

0 comments on commit 68aae0d

Please sign in to comment.