Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bunlong/svelte-csv
svelte-csv is the fastest in-browser CSV (or delimited text) parser for Svelte. It is full of useful features such as CSVReader, CSVDownloader, readString, jsonToCSV, readRemoteFile, ... etc.
https://github.com/bunlong/svelte-csv
csv svelte svelte-csv sveltejs
Last synced: 5 days ago
JSON representation
svelte-csv is the fastest in-browser CSV (or delimited text) parser for Svelte. It is full of useful features such as CSVReader, CSVDownloader, readString, jsonToCSV, readRemoteFile, ... etc.
- Host: GitHub
- URL: https://github.com/bunlong/svelte-csv
- Owner: Bunlong
- License: mit
- Created: 2021-05-05T15:35:02.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-27T20:01:20.000Z (over 1 year ago)
- Last Synced: 2024-12-17T07:52:12.789Z (24 days ago)
- Topics: csv, svelte, svelte-csv, sveltejs
- Language: JavaScript
- Homepage:
- Size: 1.63 MB
- Stars: 10
- Watchers: 3
- Forks: 4
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# svelte-csv
svelte-csv is the fastest in-browser CSV (or delimited text) parser for Svelte. It is full of useful features such as CSVDownloader, readString, jsonToCSV, readRemoteFile, CSVReader, ... etc.
## đ§ Install
svelte-csv is available on npm. It can be installed with the following command:
```
npm install svelte-csv --save
```svelte-csv is available on yarn as well. It can be installed with the following command:
```
yarn add svelte-csv --save
```## âšī¸ Note on usage with SvelteKit
If you are using `svelte-csv` with SvelteKit, you need to configure `svelte.config.js` as follows:
```
kit: {
// ...
vite: {
optimizeDeps: {
include: ['papaparse']
}
}
}
```## đ Useful Features
* [x] CSVDownloader
* [x] readString
* [x] readRemoteFile
* [x] jsonToCSV
* [ ] CSVReader## đĄ Usage
### đ CSVDownloader
If you want to open your CSV files in Excel, you might want to set `bom={true}` or `bom`, default is `false`. This option adds the so called BOM byte `'\ufeff'` to the beginning of your CSV files and tells Excel that the encoding is UTF8.
#### Link
```javascript
import { CSVDownloader } from 'svelte-csv';Download
```
#### Link
```javascript
import { CSVDownloader } from 'svelte-csv';Download
```
### đ readString
```javascript
import { readString } from 'svelte-csv';const str = `Column 1,Column 2,Column 3,Column 4
1-1,1-2,1-3,1-4
2-1,2-2,2-3,2-4
3-1,3-2,3-3,3-4
4,5,6,7`;const results = readString(str);
```### đ readRemoteFile
```javascript
import { readRemoteFile } from 'svelte-csv'readRemoteFile(
url,
{
complete: (results) => {
console.log('Results:', results)
}
}
);
```### đ jsonToCSV
```javascript
import { jsonToCSV } from 'svelte-csv';const jsonData = `[
{
"Column 1": "1-1",
"Column 2": "1-2",
"Column 3": "1-3",
"Column 4": "1-4"
},
{
"Column 1": "2-1",
"Column 2": "2-2",
"Column 3": "2-3",
"Column 4": "2-4"
},
{
"Column 1": "3-1",
"Column 2": "3-2",
"Column 3": "3-3",
"Column 4": "3-4"
},
{
"Column 1": 4,
"Column 2": 5,
"Column 3": 6,
"Column 4": 7
}
]`;const results = jsonToCSV(jsonData);
```## đ Changelog
Latest version 1.2.8 (2022-02-15):
* Fix `'/node_modules/papaparse/papaparse.min.js?v=8573111b' does not provide an export named 'default`
Details changes for each release are documented in the [CHANGELOG.md](https://github.com/Bunlong/svelte-csv/blob/master/CHANGELOG.md).
## â Issues
If you think any of the `svelte-csv` can be improved, please do open a PR with any updates and submit any issues. Also, I will continue to improve this, so you might want to watch/star this repository to revisit.
## đ Contribution
We'd love to have your helping hand on contributions to `svelte-csv` by forking and sending a pull request!
Your contributions are heartily ⥠welcome, recognized and appreciated. (âŋâ âŋâ )
How to contribute:
- Open pull request with improvements
- Discuss ideas in issues
- Spread the word
- Reach out with any feedback## âī¸ License
The MIT License [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)