Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Add an option to switch between datarows and datacolumns #2

Closed
thejh opened this Issue Mar 29, 2012 · 1 comment

Comments

Projects
None yet
2 participants

thejh commented Mar 29, 2012

How about adding an option for switching between the normal format and one where rows and columns are reversed?

E.g. turn


byte  count
----  -----
10    475  
32    6689 
33    12   
34    134  
35    11   
36    1    
37    1    
38    29   
39    417  
40    110  
41    110  
42    49   
43    7    
44    505  

into

byte  | 10  32   33 34  35 36 37 38 39  40  41  42 43 44
count | 475 6689 12 134 11 1  1  29 417 110 110 49 7  505
Owner

eldargab commented Mar 29, 2012

It will be a kind of mess whereas doing this manualy for the concrete use case is as simple as:

var table = {
    "byte": [],
    "count": []
}

data.forEach(function (line) {
    table["byte"].push(line["byte"])
    table["count"].push(line["count"])
})

var t = new EasyTable

for (var key in table) {
    t.cell('Prop / SampleNo', key)
    table[key].forEach(function (sample, index) {
        t.cell(index + 1, sample)
    })
    t.newLine()
}

console.log(t.toString())

Just few extra lines of code

@eldargab eldargab closed this Mar 29, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment