question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is xlsx to csv conversion possible ?

See original GitHub issue

Found this piece of code in the docs, but it doesn’t seem to work. I have an input which is an s3 url of xlsx file input https://modulus.s3-****/Content.xlsx

var output_file_name = "out.csv";
var stream = XLSX.stream.to_csv(worksheet);
stream.pipe(fs.createWriteStream(output_file_name));

Is this the right way to do when input is an url also if its so how to generate worksheet from xlsx file

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
SheetJSDevcommented, Sep 13, 2022

XLSX.utils.sheet_to_csv(ws) is a string, you can just send that in the response.

1reaction
SheetJSDevcommented, Sep 13, 2022

Assuming you are running in a newer version of NodeJS, use fetch to download the data and loop through the worksheets:

const XLSX = require("xlsx"), fs = require("fs");
const url = "...";

(async() => {
  const wb = XLSX.read(await (await fetch(url)).arrayBuffer());
  wb.SheetNames.forEach((name, idx) => {
    const ws = wb.Sheets[name];
    fs.writeFileSync(`out.${idx}.csv`, XLSX.utils.sheet_to_csv(ws));
  });
})();

If the file is not public, the AWS demo in the docs has an example using the official aws-sdk module to fetch an object, parse, and log the first worksheet

Read more comments on GitHub >

github_iconTop Results From Across the Web

Excel to CSV - Convert your XLSX to CSV for Free Online
Do you want to convert a XLSX file to a CSV file ? Don't download software - use Zamzar to convert it for...
Read more >
Using Microsoft Excel to convert .xls, .xlsx file into a .csv ...
Using Microsoft Excel to convert .xls, .xlsx file into a .csv format · 1. Open your excel file. · 2. Click on File...
Read more >
XLSX to CSV Converter
XLSX to CSV Converter. CloudConvert is an online document and spreadsheet converter. Amongst many others, we support PDF, XLSX, XLS, CSV, ODS.
Read more >
Convert Excel to CSV (comma delimited) and UTF-8
The use of Google Spreadsheets for .xlsx to .csv conversions seems a very simple workaround: In Google Spreadsheet, click File > Import. Import ......
Read more >
Save an Excel spreadsheet as a CSV file
Convert an Excel spreadsheet into a Comma Separated Value file to import large lists or reduce the chance of import errors when uploading ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found