personium / personium-engine

Additional module for personium-core to enable server-side JavaScript execution.
Apache License 2.0
16 stars 7 forks source link

CSV parser support #63

Closed dixonsiu closed 3 years ago

dixonsiu commented 5 years ago

It would be nice to use a library like this to support parsing and exporting of CSV file within the Engine Script.

yoh1496 commented 3 years ago

Hi @dixonsiu

How about using Papa Parse ?

After approving #148, we can use Papa Parse like below.

function csvtest(request) {
  const Papa = require("./papaparse.min");
  const dat= Papa.parse("aaa,bbb,ccc\nhoge,foo,bar\n111,222,333", {header: true});
  return {
    status: 200,
    headers: { "Content-Type": "application/json" },
    body: [
      JSON.stringify(dat),
    ],
  };
}

image

dixonsiu commented 3 years ago

Yes, I was already using papaparse by modifying the first line.

exports.Papa = (function(root, factory)
yoh1496 commented 3 years ago

Oh sorry. I don't know that you solved it already. Could you close this issue?

By the way, the modifying lines is not good in perspective of maintainability 😭

dixonsiu commented 3 years ago

Yup, hopefully, with your pull request, I don't have to write the silly one line anymore.