betto_codec_csv 0.1.0-dev.1
betto_codec_csv: ^0.1.0-dev.1 copied to clipboard
A configurable CSV parser for Dart with RFC 4180 support. Decodes delimiter-separated text into a RecordSet.
// Copyright 2026 The Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import 'package:betto_codec_csv/betto_codec_csv.dart';
void main() {
final result = Decoder().decode('a,b,c\nd,e,f');
print(result.recordAt(0).values); // [a, b, c]
print(result.recordAt(1).values); // [d, e, f]
final csv = Decoder(dialect: CsvDialect(hasHeaderRow: true));
final result2 = csv.decode('first,second,third\n1,2,3');
print(result2.header!.fieldNames); // [first, second, third]
print(result2.first['first']!.value); // 1
}