Created
March 9, 2016 17:57
-
-
Save peterkappus/0b59a871a4148838f7f1 to your computer and use it in GitHub Desktop.
Simple HTML/JS tool to convert actuals data from finance format to the format required by the Del Ops reporting tools.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body xonload="convert()"> | |
<script language="javascript"> | |
function convert(){ | |
source_rows = document.getElementById('raw_input').value.split("\n") | |
headers = source_rows.shift().split("\t"); | |
//rows now contains only data | |
data = [] | |
for(i in source_rows){ | |
interim_row_data = {} | |
//skip rows containing "total" | |
if(source_rows[i].toLowerCase().indexOf("total") > 0) { | |
continue; | |
} | |
//skip rows containing "total" | |
if(source_rows[i].split("\t")[0] == "") { | |
continue; | |
} | |
for (column in headers) { | |
value = source_rows[i].split("\t")[column].trim(); | |
interim_row_data[headers[column]] = value.replace("SALARIES","CSs") | |
.replace("INTERIMS","Interims") | |
.replace("OTHER","other_costs") | |
//categorise capital and income as other_costs for now. | |
//.replace("CAPITAL","other_costs") | |
//.replace("INCOME","other_costs") | |
//convert TECHNOLOGY to "Government Technology" since this is what the report is looking for. | |
.replace("TECHNOLOGY","Government Technology") | |
//wipe out pound signs | |
.replace("£",""); | |
} | |
//now populate new rows | |
//loop through dates for this row | |
for (i = 3; i <= 12; i++){ | |
obj = {} | |
obj['group'] = interim_row_data['group']; | |
obj['type'] = interim_row_data['type']; | |
obj['team'] = interim_row_data['team']; | |
obj['date'] = headers[i]; | |
obj['value'] = interim_row_data[headers[i]]; | |
// | |
data.push(obj) | |
} | |
//now output them | |
output_buffer ="" | |
for(i in data) { | |
//console.log(i) | |
output_buffer += [data[i]['group'],data[i]['team'],data[i]['type'],data[i]['date'],data[i]['value']].join("\t") + "\n"; | |
} | |
} | |
document.getElementById("dest").value = output_buffer; | |
} | |
</script> | |
<h1> Actuals conversion Script</h1> | |
<h2>Step 1: Paste the raw data (with headers) in here</h2> | |
<p>NOTE: Headers should be: <i>group team type 01/04/2015 01/05/2015 01/06/2015 01/07/2015 01/08/2015 01/09/2015 01/10/2015 01/11/2015 01/12/2015 01/01/2016</i></p> | |
<br> | |
<textarea id="raw_input" onchange="convert()" style="width:100%" rows="20"></textarea> | |
<br> | |
<h2>Step 2: Copy this and paste into the DATA_INPUT tab in <a href="https://docs.google.com/spreadsheets/d/1qxwnWpTKc5OnsuqpErDZ_kbS0AxRVQWs5FYjp7_Nad8/edit#gid=2064383530">this Google Spreadsheet</a>.</h2> | |
<br> | |
<textarea id="dest" style="width:100%" rows="20"></textarea> | |
<p>2016 - Peter Kappus (Delivery Ops)</p> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment