data-conversion

How To Convert Json to google visualization datatable

断了今生、忘了曾经 提交于 2019-12-02 03:15:51
问题 I have a method with ajax call to the server to get json result var jsonData = $.ajax({ url: '/Reports/GetJsonData', type: 'GET', dataType: 'json', error: function (err) { alert("Error : "+err.statusText); } }).responseText; Then I can get the Following Json result to the "jsonData" variable. [ {"LineName":"L1","Car":23,"Bus":0,"Motorcycle":0,"Person":0,"Others":0} ,{"LineName":"L2","Car":0,"Bus":0,"Motorcycle":6,"Person":0,"Others":0} ,{"LineName":"L3","Car":10,"Bus":20,"Motorcycle":36,

How To Convert Json to google visualization datatable

◇◆丶佛笑我妖孽 提交于 2019-12-01 22:45:13
I have a method with ajax call to the server to get json result var jsonData = $.ajax({ url: '/Reports/GetJsonData', type: 'GET', dataType: 'json', error: function (err) { alert("Error : "+err.statusText); } }).responseText; Then I can get the Following Json result to the "jsonData" variable. [ {"LineName":"L1","Car":23,"Bus":0,"Motorcycle":0,"Person":0,"Others":0} ,{"LineName":"L2","Car":0,"Bus":0,"Motorcycle":6,"Person":0,"Others":0} ,{"LineName":"L3","Car":10,"Bus":20,"Motorcycle":36,"Person":13,"Others":0} ] I want to convert this result to the following format [['LineName', 'Car', 'Bus',

How to improve buffer size determination for printfing various integer types?

对着背影说爱祢 提交于 2019-12-01 20:21:44
When converting an integer to text, typically I create a big buffer to use with sprintf() to hold any potential result. char BigBuffer[50]; sprintf(BugBuffer, "%d", SomeInt); I'd like to more space efficient and certainly portable, so instead of 50 , found the alternative: (sizeof(integer_type)*CHAR_BIT*0.302) + 3 // 0.0302 about log10(2) #define USHORT_DECIMAL_BUFN ((size_t) (sizeof(unsigned short)*CHAR_BIT*0.302) + 3) #define INT_DECIMAL_BUFN ((size_t) (sizeof(int) *CHAR_BIT*0.302) + 3) #define INTMAX_DECIMAL_BUFN ((size_t) (sizeof(intmax_t) *CHAR_BIT*0.302) + 3) int main() { char usbuffer

Need help converting a BMP image to a matrix in [R]?

僤鯓⒐⒋嵵緔 提交于 2019-12-01 19:47:15
I'm very new to R, and I was wondering if there was a simple way to convert a BMP image to a matrix in R. Mainly, I'm looking for any package that can help. The values of each element in the matrix would correspond to colors. A search for "bmp" on the CRAN packages list pulls up bmp and some others, for brevity I will just use this package. library(bmp) fl <- system.file("images", "5HT1bMARCM-F000001_seg001_lsm.bmp", package = "bmp") b <- read.bmp(fl) This object is an array, with some information about the file: str(b) int [1:206, 1:206, 1:3] 107 111 119 123 115 119 119 139 143 143 ... - attr

How do I convert an array of arrays into a multi-dimensional array in Python?

时光总嘲笑我的痴心妄想 提交于 2019-12-01 19:30:38
I have a NumPy array (of length X) of arrays, all of which are of the same length (Y), but which has type "object" and thus has dimension (X,). I would like to "convert" this into an array of dimension (X, Y) with the type of the elements of the member arrays ("float"). The only way I can see to do this is "manually" with something like [x for x in my_array] Is there a better idiom for accomplishing this "conversion"? For example I have something like: array([array([ 0., 0., 1., 0., 0., 0., 0., 0., 0., 0.]), array([ 0., 1., 0., 0., 0., 0., 0., 0., 0., 0.]), array([ 0., 0., 1., 0., 0., 0., 0.,

Converting polygon coordinates from Double to Long for use with Clipper library

妖精的绣舞 提交于 2019-12-01 17:17:29
I have two polygons with their vertices stored as Double coordinates. I'd like to find the intersecting area of these polygons, so I'm looking at the Clipper library (C++ version). The problem is, Clipper only works with integer math (it uses the Long type). Is there a way I can safely transform both my polygons with the same scale factor, convert their coordinates to Longs, perform the Intersection algorithm with Clipper, and scale the resulting intersection polygon back down with the same factor, and convert it back to a Double without too much loss of precision? I can't quite get my head

Converting arraybuffer to string : Maximum call stack size exceeded

[亡魂溺海] 提交于 2019-12-01 16:12:30
This is my line of code. var xhr = new XMLHttpRequest(); xhr.open('GET',window.location.href, true); xhr.responseType = "arraybuffer"; xhr.onload = function(event) { debugger; console.log(" coverting array buffer to string "); alert(String.fromCharCode.apply(null, new Uint8Array(this.response))); }; xhr.send(); That request is making to a pdf url which is around 3 MB in size. Read few thread with same error, telling that there must be some recursive call but I do not see any recursive call here. Any help ? le_m The error is caused by a limitation in the number of function arguments. See

How %a conversion work in printf statement?

元气小坏坏 提交于 2019-12-01 15:33:28
Maybe this doesn't belong on SO but I don't know where else. I have to reimplement printf(3) with C without using any function that would do the conversion for me, I'm nearly done, but I'm stuck on %a , I really don't understand what is happening here for example: printf("%a\n", 3.0); //#=> 0x1.8p+1 printf("%a\n", 3.1); //#=> 0x1.8cccccccccccdp+1 printf("%a\n", 3.2); //#=> 0x1.999999999999ap+1 printf("%a\n", 3.3); //#=> 0x1.a666666666666p+1 printf("%a\n", 3.4); //#=> 0x1.b333333333333p+1 printf("%a\n", 3.5); //#=> 0x1.cp+1 printf("%a\n", 3.6); //#=> 0x1.ccccccccccccdp+1 Of course I read the

Excel to various JSON objects

半腔热情 提交于 2019-12-01 12:25:30
I have this Excel table: country year 1 2 3 4 Netherlands 1970 3603 4330 5080 5820 Netherlands 1971 3436 4165 4929 5693 Netherlands 1972 3384 4122 4899 5683 Sweden 1970 1479 1963 2520 3132 Sweden 1971 1497 1985 2547 3163 Sweden 1972 1419 1894 2445 3055 I would like to experiment with two JSON formats. Either: data = [ Netherlands : { 1970 : [3603, 4330, 5080, 5820], 1971 : [...], }, Sweden : { 1970 : [...] }, ] Or using the headers 1,2,3,4 as x-values: data = [ Netherlands : { 1970 : [{x: 1, y: 3603}, {x: 2, y: 4330}, {x: 3, y: 5080}, {x: 4, y: 5820}], 1971 : [...], }, Sweden : { 1970 : [...]

Shapefile to raster conversion in R?

二次信任 提交于 2019-12-01 04:06:16
I have a shapefile downloaded from the worldwildlife.org for the terrestrial ecoregions of the world. The file can be loaded here: http://worldwildlife.org/publications/terrestrial-ecoregions-of-the-world . It comes as a standard shape file and I would like to do two things with it. First: take the shapefile from my local directory and clip it to an extent of eastern North America (ext= extent (-95, -50, 24, 63)) # Read shapefile using package "maptools" eco_shp <- readShapeLines("F:/01_2013/Ecoregions/Global/wwf_terr_ecos.shp", proj4string=CRS("+proj=utm +zone=33 +datum=WGS84")) # Set the