@@ -34,7 +34,7 @@ module.exports = class GetDataDataAdaptor extends BaseService
3434 true
3535 else
3636 false
37-
37+
3838 # accepts handsontable row-oriented table data as input and returns dataFrame
3939 ###
4040 @param {Array} tableData - array of objects
@@ -46,14 +46,14 @@ module.exports = class GetDataDataAdaptor extends BaseService
4646 # by default data types are not known at this step
4747 # and should be defined at Clean Data step
4848 # colTypes = ('symbolic' for [1...tableData.nCols])
49-
49+
5050 if Object .prototype .toString .call (tableData[0 ]) == " [object Object]"
5151 header = @ getHeaders tableData[0 ]
5252 tableData = @ extractData tableData
53-
53+
5454 if header .length is 0
55- for i in [0 ... tableData[0 ]- 1 ]
56- header .push (i)
55+ for i in [0 ... tableData[0 ]. length - 1 ]
56+ header .push (i . toString () )
5757
5858 # generating types for all columns
5959 tempDF =
@@ -62,7 +62,7 @@ module.exports = class GetDataDataAdaptor extends BaseService
6262 nCols : header .length
6363 data : tableData
6464 dataType : @DATA_TYPES .FLAT
65- purpose : ' json'
65+ purpose : ' json'
6666 newDataFrame = @ transformArraysToObject tempDF
6767 @dataService .inferTypes newDataFrame
6868 .then ( (typesObj ) =>
@@ -73,7 +73,7 @@ module.exports = class GetDataDataAdaptor extends BaseService
7373 data : tableData
7474 dataType : @DATA_TYPES .FLAT
7575 types : typesObj .dataFrame .data
76- purpose : ' json'
76+ purpose : ' json'
7777 )
7878
7979 ###
@@ -111,21 +111,21 @@ module.exports = class GetDataDataAdaptor extends BaseService
111111 # generate titles and references
112112 count data
113113 return _col
114-
114+
115115 # @TODO : merge this function with jsonToFlatTable.
116116 extractData : (data )->
117-
117+
118118 if not Array .isArray data
119119 throw new Error " not a valid array. Cannot extract data"
120120
121121 parsedData = []
122122 headers = @ getHeaders data[0 ]
123-
123+
124124 getValue = (path ,obj ) ->
125125 if path .split (' .' ).length == 1
126- if ( obj[path] == null or obj[path] == undefined )
127- return null
128- else
126+ if ( obj[path] == null or obj[path] == undefined )
127+ return null
128+ else
129129 return obj[path]
130130 pathTokens = path .split (' .' )
131131 newObj = obj[pathTokens .shift ()]
@@ -234,7 +234,7 @@ module.exports = class GetDataDataAdaptor extends BaseService
234234
235235 enforceTypes : (dataFrame , types = null ) ->
236236 types = types || dataFrame .types
237- if types? and dataFrame?
237+ if types? and dataFrame?
238238 Object .keys (types).forEach (type)=>
239239 dataFrame .data .forEach (dataRow)=>
240240 switch types[type]
@@ -251,5 +251,5 @@ module.exports = class GetDataDataAdaptor extends BaseService
251251 # stats.js lib for a key "indicator.id" checks obj["indicator"]["id"]
252252 # to fix that, replacing all "." with "_"
253253 obj[h .replace (' .' ,' _' )] = entry[key]
254- obj
254+ obj
255255 return Object .assign {}, dataFrame, {data : formattedData}
0 commit comments