Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSVからJSONに変換するGulpプラグインをつくる #9

Closed
miya0001 opened this issue Feb 24, 2017 · 7 comments
Closed

CSVからJSONに変換するGulpプラグインをつくる #9

miya0001 opened this issue Feb 24, 2017 · 7 comments
Assignees

Comments

@miya0001
Copy link
Contributor

miya0001 commented Feb 24, 2017

CSVのフォーマットは以下のとおり

menu,title,lat.lng,content,...
串本,橋杭岩,12.345,123.45,これは橋杭岩です,...

これを以下のようなフォーマットのJSONに変換する

{
  "串本": [
    {
      "title": "橋杭岩"
      "lat": "12.345",
      "lng": "123.45",
      "content": "これは橋杭岩です"
    },
    {
      ...
    },
    ...
  ]
}
@kamataryo
Copy link
Contributor

誰か着手されてますか?
いなければやります!

@miya0001
Copy link
Contributor Author

お願いします!

@miya0001
Copy link
Contributor Author

miya0001 commented Feb 24, 2017

あっ、これじゃだめだ。

menu.json串本.json にわけて出力されるといいかも。

menu.json は、menu っていう列の単純な配列。
串本.json は、menu串本と記述された行の配列。

[
    {
      "title": "橋杭岩",
      "lat": "12.345",
      "lng": "123.45",
      "content": "これは橋杭岩です"
    },
    {
      ...
    },
    ...
]

最終的には、メニューで 串本 を選択したら 串本.json がロードされるイメージ。
日本語のファイルをgh-page上でAjaxでリクエストできるかから試していただけると。

こういう構造ならデータのメンテが非エンジニアでもできるようになるので。

@miya0001
Copy link
Contributor Author

あと、複数のCSVを扱えるようにするといいかも。たとえばデータが多いときに 串本.csvすさみ.csv みたいに分けてデータを作れるといいですね。

CSV から json に変換する gulp のプラグインのサンプルは以下にあります。
https://github.com/madefor/postal-code-api/tree/master/lib

@miya0001
Copy link
Contributor Author

あと、menuの項目は自治体とは限らないです。たとえば公衆トイレとかになるかも。

@kamataryo
Copy link
Contributor

日本語ファイル名でもOKみたいです。
https://kamataryo.github.io/test-ajax-with-gh-pages/
今からプラグインを作ります。

@kamataryo
Copy link
Contributor

done at #12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants