Since I started learning Ruby this week my solution written in it :D
require 'open-uri' require 'json' url = "https://gist.githubusercontent.com/jorinvo/7f19ce95a9a842956358/raw/e319340c2f6691f9cc8d8cc57ed532b5093e3619/data.json" data = JSON.parse(open(url).read) i = 0 File.open(DateTime.now.strftime("%Y%m%d") + ".csv", "w") do |f| f.write("Name,\"Credit Card\"") data.each do |record| if record["creditcard"] i+=1 name = record["name"].match(/\s/) ? "\""+ record["name"] +"\"" : record["name"] f.write("\n"+name+","+record["creditcard"]) end end end printf("Created CSV file, %d affected accounts detected", i)
Thanks for another great challenge Jorin :)
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Since I started learning Ruby this week my solution written in it :D
Thanks for another great challenge Jorin :)