Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/d-markey/csvloader
Simple, cross-platform Dart package to read CSV data from a Stream. Supports and extends RFC 4180.
https://github.com/d-markey/csvloader
csv csv-import dart flutter
Last synced: 26 days ago
JSON representation
Simple, cross-platform Dart package to read CSV data from a Stream. Supports and extends RFC 4180.
- Host: GitHub
- URL: https://github.com/d-markey/csvloader
- Owner: d-markey
- License: mit
- Created: 2022-03-18T22:28:31.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-12-28T23:56:13.000Z (about 1 year ago)
- Last Synced: 2024-11-10T13:41:46.041Z (2 months ago)
- Topics: csv, csv-import, dart, flutter
- Language: Dart
- Homepage: https://pub.dev/packages/csvloader
- Size: 40 KB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# csvloader
Lightweight, cross-platform Dart package to read CSV data from a `Stream`. Supports and extends RFC 4180.
[![codecov](https://codecov.io/github/d-markey/csvloader/branch/main/graph/badge.svg?token=9NBGYNW423)](https://codecov.io/github/d-markey/csvloader)
# Usage
```dart
import 'package:csvloader/csvloader.dart';Stream catalog() async* {
// CsvLoader will unescape data between quotes
yield 'Part code\tPart label\tDescription\r\n';
yield 'B1XX\tBolt\t"Your average bolt"\r\n';
yield 'S2XX\tScrew\t"Your average screw"\r\n';
yield 'N1XX\tNut\t"Nut; for bolts ""B1XX"""\r\n';
yield '9N\tNail\t"A 9"" nail"\r\n';
}void main() async {
// use "tab" as separator
final catalogCsv = CsvLoader.withHeaders(catalog(), separator: '\t');await for (var row in catalogCsv.rows) {
final code = row['Part code'];
final label = row['Part label'];
final descr = row['Description'];
print(' - $label ($code): $descr');
}
}
```