I want to get CSV data from local file and convert it into JSON object(IOS and android). Is there any plugin available that can convert a CSV file to JSON in react-native
1 Answer
You should be fine using papaparse.
Install it via npm.
npm install papaparse
Parse a CSV string to json as follows.
import PapaParse from 'papaparse'
options = {} // dummy options
PapaParse.parse(str, options);
The variable str contains the CSV. The return value is a JSON object.
There exists a convenient wrapper around papaparse for react native called react-native-csv, but it doesn’t seem to be updated frequently.