28 lines
639 B
JavaScript
28 lines
639 B
JavaScript
import React from 'react';
|
|
|
|
const Input = () => {
|
|
const handleChange = (e) => {
|
|
const reader = new FileReader();
|
|
reader.onload = () => {
|
|
// @ts-ignore
|
|
document.getElementById('out').innerHTML = reader.result;
|
|
};
|
|
// start reading the file. When it is done, calls the onload event defined above.
|
|
// @ts-ignore
|
|
reader.readAsBinaryString(document.getElementById('csv-input').files[0]);
|
|
};
|
|
return (
|
|
<>
|
|
<h3>Input</h3>
|
|
<input
|
|
accept=".csv"
|
|
id="csv-input"
|
|
onChange={handleChange}
|
|
type="file"
|
|
/>
|
|
<pre id="out"><p>File contents will appear here</p></pre>
|
|
</>
|
|
);
|
|
};
|
|
export default Input;
|