How to use papa-parse-meteor?

I’m new to meteor.

I have some CSV data in my DOM which I want to transform into a table-element.

I searched a bit and found this package:

The package assumes that I know how to copy the CSV data out of my DOM into JS array.

But I cannot figure out how to do that.

The code I have so far looks like this:

<template name='dad1'>
  <h1 id='id1'>hello</h1>
  <h2 id='id2'>world</h2>
  <pre id='pre1'>

// dad1.js
if (Meteor.isClient) {
    var myv  = this.$('id1');
    var myih = myv.html();
    var myh1 = this.find('id1');
    var myh2 = this.find('id2');})}

I cannot get any data to load into my variables.

When the above code runs, my variables stay empty (according to my browser debugger).

Question: How to use papa-parse-meteor?

1 Like

See this sample I made with Papa-parse

<template name="readCSV">
    <input type="file" id="csv-file" name="files"/>
    <button type="submit" class="btn btn-primary btnReadCsv">Read</button>
  "click .btnReadCsv": function(event, template) {
      Papa.parse(template.find('#csv-file').files[0], {
          header: true,
          complete: function(results) {
               _.each(, function(csvData) {
                   console.log(csvData.empId + ' , ' + csvData.empCode);
          skipEmptyLines: true

Additionally, you can find example from here for DOM csv


Thanks mate! This helped me big time!

I am trying to get it to work on the client:

import Papa from 'meteor/harrison:papa-parse';


Papa.parse(file, {
    complete: function(results) {

However I get the error “_harrisonPapaParse2.default.parse is not a function”.

The strange thing is, when I put a breakpoint just before the parse call and run the same code in the browser console, it will work fine.

Does anyone have an idea what is going on here?

Never mind, since I am only using it on the client and it has no dependencies, the easiest solution is to just include its single file somewhere in the sources. Then it works fine.

Hey, here’s another solution from @themeteorchef - importing CSVs in case you want other approach.

1 Like

Papaparse works with npm:

npm i papaparse
import Papa from 'papaparse'

Using React 15.5 and Meteor

gj on digging up 1 year old thread. anyway since people might come across this from search engines, here is what i did:{
  'click #upload': function(event, template){
    var listId = Router.current().params._id;
    var imported = template.find('#uploadCSV').files[0];
    Papa.parse(imported, {
      header: true,
      complete(results, file){'parseUpload',, listId, (error, response) => {
            } else {
              Bert.alert('upload complete', 'success', 'growl-top-right');
parseUpload(data, listId){
    check(data, Array);
    check(listId, String);
    var user = Meteor.user();
    let postZ = {
        name: name,
        role: role
    var postY = _.extend(postZ, {
        userId: user._id,
        submitted: new Date(),
        locked: 0