映画データベースからJSONデータ取得し、指定フィールドの文字を置換
Nid: 1404
CSVデータに変換した時に扱いやすいように、指定フィールドの","を";"に置換します。
$ curl -sS "http://www.omdbapi.com/?i=tt8712204&apikey=yourapikey&plot=full" | jq '(.Genre, .Director, .Writer, .Actors) |= gsub(",\\s*";";")' { "Title": "Batwoman", "Year": "2019–", "Rated": "TV-14", "Released": "06 Oct 2019", "Runtime": "45 min", "Genre": "Action;Adventure;Crime;Drama;Sci-Fi", "Director": "N/A", "Writer": "Caroline Dries", "Actors": "Ruby Rose;Camrus Johnson;Rachel Skarsten;Meagan Tandy", "Plot": "Kate Kane seeks justice for Gotham City as Batwoman.", "Language": "English", "Country": "USA", "Awards": "3 nominations.", "Poster": "https://m.media-amazon.com/images/M/MV5BNTFlYjVlZmEtODhhMS00MjA4LWI1MjEtNGJkMWQ1YWZiY2QzXkEyXkFqcGdeQXVyNDQ0MTYzMDA@._V1_SX300.jpg", "Ratings": [ { "Source": "Internet Movie Database", "Value": "3.5/10" } ], "Metascore": "N/A", "imdbRating": "3.5", "imdbVotes": "24,844", "imdbID": "tt8712204", "Type": "series", "totalSeasons": "2", "Response": "True" }
CSVに変換。
$ curl -sS "http://www.omdbapi.com/?i=tt8712204&apikey=yourapikey&plot=full" | jq '(.Genre, .Director, .Writer, .Actors) |= gsub(",\\s*";";")' | jq -r '. | [.Title, .Year, .Rated, .Released, .Runtime, .Genre, .Director, .Writer, .Actors, .Plot, .Langage, .Country, .Poster, .Ratings[].Value, .Metascoe, .imdbRating, .imdbVotes, .imdbID, .Type, .totalSeasons, .Response] | @csv' "Batwoman","2019–","TV-14","06 Oct 2019","45 min","Action;Adventure;Crime;Drama;Sci-Fi","N/A","Caroline Dries","Ruby Rose;Camrus Johnson;Rachel Skarsten;Meagan Tandy","Kate Kane seeks justice for Gotham City as Batwoman.",,"USA","https://m.media-amazon.com/images/M/MV5BNTFlYjVlZmEtODhhMS00MjA4LWI1MjEtNGJkMWQ1YWZiY2QzXkEyXkFqcGdeQXVyNDQ0MTYzMDA@._V1_SX300.jpg","3.5/10",,"3.5","24,844","tt8712204","series","2","True"
関連記事
- 1 of 2
- next ›