I’ve downloaded my tasks data from google, and I was wondering if it was possible to import it into the tasks app?
I also would love to find an answer to this question! I use Google Tasks for thousands of items. I managed to export them in one file (Tasks.json), that has the following structure:
{
"kind": "tasks#taskLists",
"items": [
{
"kind": "tasks#tasks",
"id": "[hidden]",
"title": "2go",
"updated": "2021-04-23T21:55:42.332575Z",
"items": [
{
"notes": "Gemüse Obst Brot",
"kind": "tasks#task",
"created": "2021-04-23T09:32:50.216651Z",
"id": "[hidden]",
"title": "Einkaufen",
"task_type": "PERSONAL_TASK",
"updated": "2021-04-23T21:55:43.956751Z",
"selfLink": "https://www.googleapis.com/tasks/v1/lists/[hidden]",
"status": "needsAction"
},
{
"notes": "find an answer to this question, import / export Google Tasks, migrate from Googel to Nextcloud",
"kind": "tasks#task",
"created": "2021-04-22T13:44:01.955203Z",
"id": "[hidden]",
"title": "How to import Google Tasks to Nextcloud",
"task_type": "PERSONAL_TASK",
"updated": "2021-04-23T21:37:02.973855Z",
"selfLink": "https://www.googleapis.com/tasks/v1/lists/[hidden]",
"status": "needsAction"
},
and so on. Is there any way to import these tasks into the Nextcloud Tasks app?
I don’t know, if Nextcloud can import json calendar files. Can’t you export the tasks to an iCalendar file (*.ics)? You could then import that file to the Nextcloud calendar-app (assuming that the calendar app will import tasks as well, as they are part of RFC5545).
Unfortunately there is no way to export Google Tasks as an ics-file. Therefore this doesn’t work. I also didn’t find any kind of converter for this. Any other ideas?
hi, you have probably solved this issue ages ago but In case you havent;
I needed to create my own converting tool, going from google`s .json format over to .ics which nextcloud accepts.
However, what I really wanted was to have all my events and tasks displayed in the same way as google calendar on my android, thus including Simple Calendar Pro from F-droid.
Here is what I did:
Export Google tasks from here (check Google tasks in the list): https://takeout.google.com/settings/takeout
Android
* Install Simple Calendar Pro from F-Droid here: https://f-droid.org/packages/com.simplemobiletools.calendar.pro/
Computer:
* Install Node from here: Node.js — Run JavaScript Everywhere
* Place the exported .json from Google takout in the same folder as this file (index.js, provided below).
* If it isnt already, name the Google Tasks export file to Tasks.json.
* Open terminal / cmd / powershell in same folder as this file and run application with the following command: node index.js.
* If by chance the application fails, you need to manually ensure that the tasks arent broken / missing some stuff.
* Transfer the exported tasks.ics file to your phone.
You could now import the tasks.ics file to your nextcloud instance, but they wont appear in the calendar. They will appear in the tasks app if you have that installed.
However I continued with Simple Calendar as follows:
Simple Calendar Pro:
* Create a new event type called “Regular task” => three dots menu in top right => Settings => General/Manage event Types => Pluss icon and give it the color you want
* import the tasks.ics => Three dots menu in top right => Settings => Migrating/Import events from an .ics file (all the way at the bottom)
* Profit
If you`ve also already exported and imported the Events from Google Calendar (https://calendar.google.com/calendar/u/0/r/settings/export), you should now have both Google Events and Tasks in Simple calendar.
Side note, if you are importing the Events from google, make sure to select “Regular event”, when importing in Simple calendar.
Also side note, As of 28.08-24, Google doesnt provide the StartTime for the Tasks, so I default the due time and the starTime to the same time.
This isnt relevant for Simple calendar as it isnt displayed anyway, but would be apparent if you now export and sync it to Nextcloud for example.
Here is the index.js (make sure you create it as index.js on your computer):
const fs = require("fs");
function formatDate(dateStr, i, id) {
if (!dateStr) return null;
const date = new Date(dateStr);
let str = "";
try {
str = date
.toISOString()
.replace(/[-:]/g, "")
.replace(/.\d{3}Z$/, "Z");
} catch (e) {
throw new Error(`Couldn't parse the date for index ${i}, needs manual inspection ---> ${id}`);
}
return str;
}
function parseStatus(status) {
if (status === "needsAction") {
return null;
} else {
return "COMPLETED";
}
}
function getNotes(notes) {
if (!notes || notes.length === 0) {
return null;
}
return notes.replace(/\n/g, " ");
}
function googleJsonTasksToSimpleCalendarICS(tasks) {
const icsLines = [];
icsLines.push("BEGIN:VCALENDAR");
icsLines.push("PRODID:-//Simple Mobile Tools//NONSGML Event Calendar//EN");
icsLines.push("VERSION:2.0");
tasks.forEach((task, i) => {
const status = parseStatus(task.status);
const notes = getNotes(task.notes);
icsLines.push("BEGIN:VTODO");
icsLines.push(`SUMMARY:${task.title}`);
icsLines.push(`UID:${task.id}`);
icsLines.push(`LAST-MODIFIED:${formatDate(task.updated, i, task.id)}`);
icsLines.push(`DTSTART:${formatDate(task.due, i, task.id)}`);
icsLines.push(`DUE:${formatDate(task.due, i, task.id)}`);
icsLines.push(`DTSTAMP:${formatDate(task.created, i, task.id)}`);
icsLines.push('CATEGORIES:"Regular task"');
if (status) {
icsLines.push(`STATUS:${status}`);
}
if (notes) {
icsLines.push(`DESCRIPTION:${notes}`);
}
icsLines.push("END:VTODO");
});
icsLines.push("END:VCALENDAR");
return icsLines.join("\n");
}
fs.readFile("Tasks.json", "utf8", (err, data) => {
if (err) {
console.error("Error reading JSON file:", err);
return;
}
const jsonData = JSON.parse(data);
const tasks = jsonData.items[0].items;
const icsContent = googleJsonTasksToSimpleCalendarICS(tasks);
fs.writeFile("tasks.ics", icsContent, (err) => {
if (err) {
console.error("Error writing ICS file:", err);
} else {
console.log("ICS file has been created successfully.");
}
});
});