{"id":13726691,"url":"https://github.com/mlms13/csv-reader","last_synced_at":"2025-04-22T16:28:24.288Z","repository":{"id":35763132,"uuid":"208709451","full_name":"mlms13/csv-reader","owner":"mlms13","description":"Client-side file picker that parses CSVs","archived":false,"fork":false,"pushed_at":"2023-01-07T09:44:42.000Z","size":497,"stargazers_count":8,"open_issues_count":8,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T16:44:17.809Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Reason","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mlms13.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-16T04:26:59.000Z","updated_at":"2021-05-27T20:30:46.000Z","dependencies_parsed_at":"2023-01-16T05:41:47.524Z","dependency_job_id":null,"html_url":"https://github.com/mlms13/csv-reader","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlms13%2Fcsv-reader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlms13%2Fcsv-reader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlms13%2Fcsv-reader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlms13%2Fcsv-reader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mlms13","download_url":"https://codeload.github.com/mlms13/csv-reader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250276585,"owners_count":21403892,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T01:03:16.809Z","updated_at":"2025-04-22T16:28:24.261Z","avatar_url":"https://github.com/mlms13.png","language":"Reason","readme":"# CSV File Input Reader\n\nAllow users to choose local CSV files, which are parsed and displayed in a table. This demonstrates the basics of file picking and parsing. In this case [Relude CSV](https://github.com/reazen/relude-csv) is used to parse the text.\n\n## What This Is\n\nThis is not a useful application (it just displays CSV files in an HTML table) and this is not a library, ready to be installed in your project (though there definitely may be some ideas worth copy-and-pasting). Instead, this is:\n\n- An exploration using a GADT to drive the parsing and UI file mask for a React file picker\n- An example of binding to the browser's [Blob](https://github.com/mlms13/csv-reader/blob/master/src/data/Blob.re) and [Drop Event](https://github.com/mlms13/csv-reader/blob/master/src/data/DropEvent.re) APIs... arguably this should be upstreamed to [reason-react](https://github.com/reasonml/reason-react/) and [bs-webapi-incubator](https://github.com/mlms13/csv-reader/blob/master/src/components/FileInput.re).\n- A demonstration of the [Relude CSV](https://github.com/mlms13/csv-reader/blob/master/src/data/DropEvent.re) string parser library\n- A playground for exploring bundling and dead-code-elimination within the Relude ecosystem\n\nIf you're building a Reason React UI that needs to support file pickers, maybe something in here will be worth stealing. :)\n\n## How It Works\n\nUltimately, the [File Input](https://github.com/mlms13/csv-reader/blob/master/src/components/FileInput.re) component is just a wrapper around `\u003cinput type=\"file\" /\u003e`. The component expects to be constructed with a `transform` prop of type:\n\n```reason\ntype transform('a) =\n  | String: transform(string)\n  | File: transform(File.t)\n  | Image: transform(Blob.t)\n  | JSON: transform(Js.Json.t)\n  | CSV: transform(list(list(string)));\n```\n\nThe `onChange` function you pass the the component will be called with a string if you used `transform=String`; it will be called with JSON if you passed `transform=JSON`, etc.\n\n## Limitations\n\n- When an invalid file is picked, the component doesn't show an error, it simply passes `None` as the `onChange` value to its parent, which doesn't differentiate \"you picked an invalid file\" from \"you picked no files.\" This could easily be fixed by passing a `result` to the parent instead of an `option` (and by using typed errors instead of strings).\n- This project tests CSVs, and I've tried JSON enough to confirm that it seems to work, but everything else is basically untested.\n\n## Run It\n\n```sh\n# install dependencies\nnpm install\n\n# compile, bundle, and run a dev server\n# then open localhost:1234 in your browser\n# click inside the dotted line to open the file picker\n# and choose any valid CSV, or drop one in the box\nnpm run dev\n```\n","funding_links":[],"categories":["Reason"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlms13%2Fcsv-reader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmlms13%2Fcsv-reader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlms13%2Fcsv-reader/lists"}