1

As I am using React in ES6 and am using Jquery-CSV library, I was unable to import using

var $ = jQuery = require('jquery');
require('./jquery.csv.js');

Found a way to import using

import * as randomName from 'jquery-csv'

Now how am I able to use

$.csv.toArrays(csv);```/```$.csv.toObjects(csv);?

I tried to play around by using names as prefix like randomName.csv.toArrays() but no luck.

EDIT:


randomName.toArray(csv); this works,

but now I am getting the following error

TypeError: csv.replace is not a function

How to solve this?

hemantmetal
  • 107
  • 10
Dhaval Jardosh
  • 7,151
  • 5
  • 27
  • 69

2 Answers2

1

Able to access the library and while passing string as input, I am able to get the them in Array.

input="This is a Random string"

randomName.csv.toArray(input)

Output: ["This is a Random string"]

Dhaval Jardosh
  • 7,151
  • 5
  • 27
  • 69
0

Same result here using React

import $ from 'jquery'
var csv  = $.csv = require('jquery-csv');
var input="This is a Random string"
tableau_d = csv.toArray(input)
alert(tableau_d)

Output : "This is a Random string"

Patrick
  • 1,717
  • 7
  • 21
  • 28