For currency exchange rates, Yahoo has a very rapid alternative to YQL in: http://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote?format=json
This is great except that the JSON format is a little unfamiliar to me. it seems I have to do something like
parsedjson.list.resources[3].resource.fields.price
to pull out the USD/VND exchange rate. Instead of accessing by index I would like to search by the name field, i.e. some function that when i input "USD/VND" returns the price just as above, but without me having to look up and hardcode the index.
Is this possible?
Thanks in advance for helping a newbie.
Related
I'm trying to use the aws price list API to get the price of a particular instance using getProducts, but it's been really frustrating to even get the price from the "response" given by the getProductsOutput. Everything is a awsJSONValue, and when I try to index into the awsJSONValue, I get a bunch of "map[] interface {}" issues that I have to continiously cast and it ends up looking really long and ugly (the command), and definitely not reproducible.
Online, there seems to be no way to get the price from this output due to the "map[] interface{}" issues that is returned in the AWS JsonValue and I can't even index into the particular values.
Does anyone have any success in getting the "price" from the getProducts api call in aws price list using Golang? If so, can anyone please show me because I've been playing around and I feel like it shouldn't be so complicated.
Is there any way I can parse through the aws.JSONValue via like a marshalling function or some sort?
Simply put, I want something like this (but in Golang, not python): Use boto3 to get current price for given EC2 instance type
Thanks!
I opened a thread yesterday asking how I should be encoding dates and times. It was suggested that the datetime object would be a good format, as in 'have the least issues'. Here's an example where date time doesn't seem to be working.
Can anyone help me understand why? I've noted an increasing tendency of Vega-Lite examples to use ISO-8601, and in fact if I change this example to use that format it works. So this is more of a 'why isn't it working with datetime'. Is this format still recommended? Does it still even work?
Apologies but I think I misled you with my comment on the other thread (now deleted). Date time objects are only used for filter transform, scale domain, and axis/legend values. I have looked through all the sample json files for Vega Lite and can find no example of specifying a data object like you do in your sample.
Instead, if you specify you data as follows, you don't need to provide a format object.
{"entity": "Wildfire", "date": "2022-10-01", "deaths": 75}
I am attempting to capture a list of all the indexes and their sizes in a way that I could capture the information using Angular's $http service and then iterate through the information using the ng-repeat preferably with something like:
<ul ng-repeat="elsindex in elsIndexHttpResponse">
<li>{{elsindex.name}}:{{elsindex.size}}</li>
</ul>
The closest thing I have found is this:
http://localhost:9200/_cat/indices?h=index,store.size
Except:
a. its responses are not in json so easily referencing it using the ng-repeat <li> elements isn't going to work; and
b. i would like, if possible, to get the size output to reflect the same unit size (like bytes).
If this involves something complicated then I'd be grateful for pointers on where I should focus.
I am using elasticsearch v1.4.4
Many thanks
I realize this question dates already, but wanted to add my 2 cents.
http://localhost:9200/_cat/indices?h=index,store.size&bytes=kb&format=json
Would actually get you exactly what you requested:
format=json -> formats the output to json
bytes=kb -> outputs the size in kilobytes
Information regarding the size unit was retrieved from cat APIs doc
Possible values for the bytes argument
Information regarding the format was an attempt in Sense, which has some auto-completion features quite useful to detect such options.
Cheers.
Index size in bytes is included with an indices stats API call:
curl http://localhost:9200/_stats/indexing,store
For nicely formatted JSON output, append ?pretty to the end of the URL:
curl http://localhost:9200/_stats/indexing,store?pretty
See the Indices stats API documentation for additional details and related information.
Just a slight modification from above answer.
curl -X GET "localhost:9200/_cat/indices?h=index,store.size&bytes=gb?pretty"
In case you want the size of a particular index, the below API works fine on Elastic Search 7.14.
curl http://10.29.61.105:9200/employee/_stats where employee is the desired index name.
I've looked at the very similarly titled post (Is there a C equivalent to Perls' Dumper() method in Data::Dumper?), regarding a C equivalent to Data::Dumper::Dumper();. I have a similar question for the Go language.
I'm a Perl Zealot by trade, and am a progamming hobbyist, and make use of Data::Dumper and similar offspring literally hundreds of times a day. I've taken up learning Go, because it looks like a fun and interesting language, something that will get me out of the Perl rut I'm in, while opening my eyes to new ways of doing stuffz... One of the things I really want is something like:
fmt.Println(dump.Dumper(decoded_json))
to see the resulting data structure, like Data::Dumper would turn the JSON into an Array of Hashes. Seeing this in Go, will help me to understand how to construct and work with the data. Something like this would be considered a major lightbulb moment in my learning of Go.
Contrary to the statements made in the C counterpart post, I believe we can write this, and since I'll be passing Dumper to Println, after compilation what ever JSON string or XML page I pass in and decode. I should be able to see the result of the decoding, in a Dumper like state... So, does any more know of anything like this that exists? or maybe some pointers to getting something like this done?
Hi and welcome to go I'm former perl hacker myself.
As to your question the encoding/json package is probably the closest you will find to a go data pretty printer. I'm not sure you really need it though. One of the reasons Data::Dumper was awesome in perl is because many times you really didn't know the structure of the data you were consuming without visually inspecting it. With go though everything is a specific type and every specific type has a specific structure. If you want to know what the data will look like then you probably just need to look at it's definition.
Some other tools you should look at include:
fmt.Println("%#v", data) will print the data in go-syntax form.
fmt.Println("%T", data) will print the data's type in go-syntax
form.
More fmt format string options are documented here: http://golang.org/pkg/fmt/
I found a couple packages to help visualize data in Go.
My personal favourite - https://github.com/davecgh/go-spew
There's also - https://github.com/tonnerre/golang-pretty
I'm not familiar with Perl and Dumper, but from what I understand of your post and the related C post (and the very name of the function!), it outputs the content of the data structure.
You can do this using the %v verb of the fmt package. I assume your JSON data is decoded into a struct or a map. Using fmt.Printf("%v", json_obj) will output the values, while %+v will add field names (for a struct - no difference if its a map, %v will output both keys and values), and %#v will output type information too.
I saw the cubism graphs and they are simply amazing. I have a big JSON file with 1000 entries that have a timestamp and a value (integer). Can Cubism graph those or not?! I can't seem to find documentation on this...
Cubism is generally intended for realtime data, but you can implement a metric that simply returns static values from a JSON file. Typically you do this by using context.metric. See the stocks demo in the Cubism intro talk for an example.