0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Excelでクロス表からJSONにする

0
Posted at

背景

図のようにExcelで混ぜ物のレシピ表を管理しているとします。
それぞれのレシピについて、JSONで1行のテキストにしたいときどうしようかという一発ネタです。
image.png

結論

下記のようにTEXTJOINで簡単にできます。
念のため説明すると、
・B列の空白でないセルについて
・"水":200 のようなJSONの要素が並んだ配列をつくり
・TEXTJOINを用いてカンマ区切りでつなげる
ということをしています。ドラッグすることでC列も同様にできます。

セルB13
="{"&TEXTJOIN(",",TRUE,IF(B2:B12="","",""""&$A$2:$A$12&""":"&B2:B12))&"}" '数式
{"水":200,"ほんだし":5,"酒":5,"砂糖":5,"しょうゆ":10,"牛肉":30,"レンコン":20,"にんじん":20,"ジャガイモ":30,"たまねぎ":20} '評価値

image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?