Skip to content

Instantly share code, notes, and snippets.

@lucasew
Created September 20, 2021 00:32
Show Gist options
  • Save lucasew/8c5f7de92b96d25eeaf0e97ae85ba09b to your computer and use it in GitHub Desktop.
Save lucasew/8c5f7de92b96d25eeaf0e97ae85ba09b to your computer and use it in GitHub Desktop.
Script to convert Google Tasks takeout export to CSV
#! /usr/bin/env node
const fs = require('fs')
const [, inputFile] = process.argv
const input = fs.readFileSync("./Tasks.json")
const data = JSON.parse(input)
function columnify(...columns) {
return ",".concat(columns.map((c) => `"${c}"`))
}
console.log(columnify(
"list_id",
"list_title",
"list_updated",
"due",
"created",
"task_id",
"task_title",
"task_type",
"task_updated",
"selfLink",
"status"
))
data.items.forEach((list) => {
const {id, title, updated, items} = list
const list_id = id
const list_title = title
const list_updated = updated
items.forEach((task) => {
const {due, created, id, completed, title, task_type, updated, selfLink, status} = task
const task_id = id
const task_title = title
const task_updated = updated
console.log(columnify(
list_id,
list_title,
list_updated,
due,
created,
task_id,
task_title,
task_type,
task_updated,
selfLink,
status
))
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment