How to show data from a remote .csv file in react?

im trying to extract data from this .csv link: https://raw.githubusercontent.com/MinCiencia/Datos-COVID19/master/output/producto74/paso_a_paso_T.csv I'm using React Papaparse and Im able to console.log the Arrays with no problem, The problem is that this branch tracks info since 2020 and I only want to show the LATEST date available (they update this branch every 2-3 days), and I only need the part that says "comuna_residencia" and "paso", I don't need any of the other information. I have tested a variaty of formulas, but can't manage to make it work.

1 answer

  • answered 2021-05-04 13:51 Latuz

    Okey guys, I managed to display the information with useState and useEffect as seen below:

    import { readRemoteFile } from "react-papaparse";
    
    const App = () => {
      const [data, setData] = useState(null);
    
      useEffect(() => {
        readRemoteFile(
          "https://raw.githubusercontent.com/MinCiencia/Datos-COVID19/master/output/producto74/paso_a_paso_T.csv",
          {
            complete: (results) => {
              setData(results);
            },
          }
        );
      }, []);
    
      return (
        <div>
          {data ? (
            <p>{JSON.stringify(data)}</p>
          ) : (
            <div className="loader">Loading...</div>
          )}
        </div>
      );
    };
    
    export default App;
    
    
    My question is, how I can filter to just get the last date available and also just the "comuna_residencia" and "paso"
    
    
    Thanks in advance.