Skip to content

Instantly share code, notes, and snippets.

@bastienrobert
Created December 5, 2017 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bastienrobert/182d328f2384a5bb36f7b824f756cfc4 to your computer and use it in GitHub Desktop.
Save bastienrobert/182d328f2384a5bb36f7b824f756cfc4 to your computer and use it in GitHub Desktop.
/********************
*
* Get a CSV from a manual generated array
*
********************/
const rows = [
["Subject", "Start date", "Start Time", "End Time"],
["Test", "05/12/2017", "10:00"],
["Test2", "05/12/2017", "12:00"]
]
let csvContent = "data:text/csv;charset=utf-8,"
rows.forEach(function(rowArray){
if (rowArray != rows[0]) {
let endDate = rowArray[2].split('')
endDate[1] = parseInt(endDate[1]) + 2
endDate = endDate.join('')
rowArray.push(endDate)
}
let row = rowArray.join(",")
csvContent += row + "\r\n"
})
var encodedUri = encodeURI(csvContent)
var link = document.createElement("a")
link.setAttribute("href", encodedUri)
link.setAttribute("download", "my_data.csv")
document.body.appendChild(link)
link.click()

EDT

Bored to get a paper planning, I always forgot. So this script (gonna be better soon) allows me to transform an array to a CSV, to import it on my Calendar.

TODO

  • Form (with HTML and custom style) to enter it
  • Managing TD, TP, LV2 & Modules
  • Beautify the code
  • Set in production
  • Ask for a Google Auth (optionnal) for automatic import
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment