I am trying to display csv file data to frontend in reactjs. i read csv file using papaparse and i am getting all data
["0.122584", "0.785882", "0.954039", "0.353008"]
...
...
["0.122584", "0.785882", "0.886715", "-0.626392"]
and want to to display this array data in the form of table.
I tried this
class Panel extends React.Component {
constructor(){
super();
this.state={
csvfile:undefined,
data:null
};
}
handleChange = event =>{
this.setState({
csvfile:event.target.files[0]
});
};
importCSV = () =>{
const { csvfile } = this.state;
Papa.parse(csvfile, {
complete: this.updateData,
header: false
});
};
updateData(result){
var data = result.data;
console.log(">>>>>")
this.setState({
data:data
})
console.log(data)
}
render(){
return(
<Table bordered>
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>{this.state.data}</td>
<td>Otto</td>
<td>@mdo</td>
</tr>
</tbody>
</Table>
)
}
But it is not working well. it is displaying all data in single cell only. i want each value in different cell. I am a beginner in reactJs.
Thanks.