Skip to content

Commit

Permalink
Conversion from xlsx to csv
Browse files Browse the repository at this point in the history
  • Loading branch information
ta-Hirose committed Aug 17, 2022
1 parent 18816cf commit 8c9834e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion libs/postprocess/xlsx_converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ export class XLSXConverter {
const workbook = await readXLSX(targetPath);
const sheetData = workbook.Sheets[workbook.SheetNames[0]];
const csv = xlsx.utils.sheet_to_csv(sheetData);
Deno.writeTextFileSync(targetPath, csv);
const splitPath = targetPath.split("/");
const dir = splitPath.slice(0, -1).join("/");
const fileName = splitPath[splitPath.length - 1].replace(
/\..xlsx$/,
".csv",
);
const filePath = dir + "/" + fileName;
Deno.writeTextFileSync(filePath, csv);
}
}

0 comments on commit 8c9834e

Please sign in to comment.