I’m trying to build a workflow that triggers when a file is added to a folder.
I’m struggling with “reading the file contents” part. It gives me gibberish.
I managed to detect the file being added to the drive, and download it.
But when I try to read it, it’s unreadable.
What I ideally need is to have the content of the file as a JS array or object. There is only one file and one “tab” in the file.
How can I read this file and extract its data as an array?
I tried using the Beta Python module, to use Panda.
But I got Missing optional dependency 'openpyxl'. Use pip or conda to install openpyxl.
error.
Edit: Simply loading the module worked.
import pandas as pd
import openpyxl
But I ran into another issue which doesn’t seem PipeDream-related, so I opened a SO question:
Managed to do it using nodejs
import fs from "fs";
import xlsx from 'xlsx';
export default defineComponent({
async run({ steps, $ }) {
const workbook = xlsx.readFile('/tmp/file.xlsx');
let workbook_sheet = workbook.SheetNames;
let workbook_response = xlsx.utils.sheet_to_json(
workbook.Sheets[workbook_sheet[0]]
);
return workbook_response;
}
});
1 Like