org-report-stats/utils.mjs

35 lines
750 B
JavaScript
Raw Normal View History

2023-04-18 21:59:16 +02:00
import fs from "node-fs";
2023-03-15 22:00:07 +01:00
export const headersTsv = 'amount\t' +
2023-04-18 22:54:38 +02:00
'content\t' +
'description\t' +
'destination\t' +
'end\t' +
'kind of activity\t' +
'person\t' +
'place\t' +
'source\t' +
'start\t' +
'unique id\t' +
'url\t'
2023-04-18 21:59:16 +02:00
2023-04-18 22:54:38 +02:00
const outputAbsolutePath = '/home/tykayn/Nextcloud/ressources/social sorting/output/';
2023-04-18 21:59:16 +02:00
export async function writeFileInOuputFolderFromJsonObject(fileName, jsonObjectThing) {
2023-04-18 22:54:38 +02:00
// console.log('statistics.dates', statistics.dates)
2023-04-18 21:59:16 +02:00
2023-04-18 22:54:38 +02:00
return await fs.writeFile(
2023-09-21 18:15:45 +02:00
`${outputAbsolutePath}${fileName}`,
JSON.stringify(jsonObjectThing, null, 2),
2023-04-18 22:54:38 +02:00
"utf8",
(err) => {
if (err) {
console.log(`Error writing file: ${err}`);
} else {
console.log(`File ${fileName} is written successfully!`);
}
}
);
2023-04-18 21:59:16 +02:00
}