dart_datakit 1.3.1 copy "dart_datakit: ^1.3.1" to clipboard
dart_datakit: ^1.3.1 copied to clipboard

Data manipulation library.

example/example.dart

import 'package:dart_datakit/dart_datakit.dart';

void main() {
  // Define a schema: 'id' must be int, 'name' must be String, 'value' has no enforced type.
  final schema = DatacatSchema(
    requiredColumns: {
      'id': int,
      'name': String,
      'value': null,
    },
    strictColumns: true,
  );

  // Create a Datacat with the schema.
  final datacat = Datacat.withSchema(
    schema: schema,
    rows: [
      [1, 'Alice', 10],
      [2, 'Bob', 20],
      [3, 'Charlie', null],
    ],
  );

  print('Datacat with schema:');
  print(datacat);

  // Transformation: convert 'name' to uppercase.
  Transformations.toUpperCase(datacat, 'name');
  print('After toUpperCase:');
  print(datacat);

  // Additional functionalities.
  print('Head (first 2 rows):');
  print(datacat.head(2));

  print('Sorted by "value" descending:');
  print(datacat.sortBy('value', ascending: false));

  print('Summary statistics:');
  print(datacat.describe());

  // Pivot Datacat example:
  final pivoted = Pivots.pivot(datacat, 'id', 'name', 'value');
  print('Pivoted Datacat:');
  print(pivoted);

  // Demonstrate schema enforcement:
  try {
    // This should throw an error because 'id' expects int.
    datacat.updateCell(0, 'id', 'InvalidType');
  } catch (e) {
    print('Caught error during schema check: $e');
  }
}
0
likes
130
points
74
downloads

Publisher

unverified uploader

Weekly Downloads

Data manipulation library.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

csv, excel

More

Packages that depend on dart_datakit