Skip to content

Commit b948333

Browse files
Release 0.1.9
2 parents ee89ac0 + 697ae1c commit b948333

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

app/scripts/analysis/GetData/GetDataDataAdaptor.service.coffee

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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}

app/scripts/analysis/GetData/GetDataMainCtrl.controller.coffee

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,10 @@ module.exports = class GetDataMainCtrl extends BaseCtrl
164164
if file?
165165
# TODO: replace d3 with datalib
166166
dataResults = @d3.csv.parseRows file
167-
data = @dataAdaptor.toDataFrame dataResults
168-
@passReceivedData data
167+
@dataAdaptor.toDataFrame dataResults
168+
.then( (dataFrame)=>
169+
@passReceivedData dataFrame
170+
)
169171
)
170172

171173
## Other instance methods

0 commit comments

Comments
 (0)