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.

Read from a csv file

See original GitHub issue

I have a csv file uploaded in input type file and I want to read this file the exceljs but I don’t know how ? can you please help me with that. In the documentation it’s not mention how to read before prepossessing with exceljs this are the examples in the documentation :

// read from a file
var workbook = new Excel.Workbook();
workbook.csv.readFile(filename)
    .then(function(worksheet) {
        // use workbook or worksheet
    });
 
// read from a stream
var workbook = new Excel.Workbook();
workbook.csv.read(stream)
    .then(function(worksheet) {
        // use workbook or worksheet
    });
 
// pipe from stream
var workbook = new Excel.Workbook();
stream.pipe(workbook.csv.createInputStream());

This the begining of my code :

function ValidateFile(input) {
  
    var files = input.files || [];
    if (!files.length) return;
    var file = files[0];

    fileName = file.name;
    
   //what to do here ???

   var workbook = new Excel.Workbook();
   workbook.csv.read(stream)
    .then(function(worksheet) {
        
    });
}

Wich one can I use and how ? Thank you.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:3
  • Comments:8

github_iconTop GitHub Comments

20reactions
1whatleytaycommented, Jul 7, 2020

This is really frustrating. Xlsx works really well in browser via the load method if you load an ArrayBuffer via FileReader, but load is inexplicably missing for CSVs. I can’t imagine why, a corresponding writeBuffer method exists, why not load??

The need to load a csv file is always present on browser, even if it is slower or less efficient. It makes absolutely no sense why CSV requires a node environment but Xlsx does not.

14reactions
Shiko1stcommented, May 12, 2020

Is there a chance to read csv and xlsx in browser?

Read more comments on GitHub >

github_iconTop Results From Across the Web

csv — CSV File Reading and Writing — Python 3.11.1 ...
The csv module implements classes to read and write tabular data in CSV format. It allows programmers to say, “write this data in...
Read more >
Reading and Writing CSV Files in Python - Real Python
Reading from a CSV file is done using the reader object. The CSV file is opened as a text file with Python's built-in...
Read more >
Reading CSV files in Python - GeeksforGeeks
USing csv.reader(): At first, the CSV file is opened using the open() method in 'r' mode(specifies read mode while opening a file) which ......
Read more >
Reading CSV files in Python - Programiz
Example 1: Read CSV files with csv.reader() ... Here, we have opened the innovators.csv file in reading mode using open() function. ... Then,...
Read more >
Pandas Read CSV - W3Schools
Pandas Read CSV ; Load the CSV into a DataFrame: · pandas as pd df = pd.read_csv('data.csv') print(df.to_string()) ; Print the DataFrame without...
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