scidart_io 0.0.1-dev.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 47

SciDart IO #

SciDart IO is file manipulation library compatible with SciDart. This library is part of SciDart project.

Goals #

A data manipulation library compatible with SciDart. The focus platform is PC for while to simplify the development.

Motivation #

Make easy save and retrieve data from SciDart.

Link to the Pub repository: https://pub.dev/packages/scidart_io

Installation #

You can follow instruction in the Pub web site: https://pub.dev/packages/scidart_io#-installing-tab-

SciDart IO structure #

  • IO: File manipulation libraries;
    • csv: CSV file manipulation;
    • txt: text file manipulation;

Examples #

CSV #

import 'package:scidart/numdart.dart';
import 'package:scidart_io/scidart_io.dart';

void main() async {
  // read stock_data.csv file in the same directory of the current
  // script
  // the delimiter of this file is ',' but can be any character
  // the reader skip one line in the header of the file and
  // one line at the end of the file
  var data = await readCSV('stock_data.csv', delimiter: ',', skipHeader: 1, skipFooter: 1);
  
  print(data); // show the data
  
  // generate a 2d array data for test
  var data2 = Array2d([
    Array([1, 2, 3, 4, 5]),
    Array([2, 3, 4, 5, 6]),
    Array([3, 4, 5, 6, 7]),
    Array([4, 5, 6, 7, 8]),
    Array([5, 6, 7, 8, 9]),
  ]);
  
  // define a file name
  var fileName = 'data_array.csv';
  
  // save the data in a CSV file
  await writeLinesCSV(data2, fileName);
  
  // read the same data again and convert to Array2d again
  var data2Read = await readCSV(fileName, convertToArray2d: true);
  
  // show the data
  print(data2Read);
}

TXT #

import 'package:scidart/numdart.dart';
import 'package:scidart_io/scidart_io.dart';

void main() async {
  // define a data for tests
  var data = Array2d([
    Array([1, 2, 3, 4, 5]),
    Array([2, 3, 4, 5, 6]),
    Array([3, 4, 5, 6, 7]),
    Array([4, 5, 6, 7, 8]),
    Array([5, 6, 7, 8, 9]),
  ]);
  
  // define a file name
  var fileName = 'data_array.txt';
  
  // write lines in the txt files
  await writeLinesTxt(data.toString().split('\n'), fileName);
  
  // read the line again
  var dataRead = await readLinesTxt(fileName);
  
  // show in the terminal
  print(dataRead);
  
  // to write plain string in a file, just use writeTxt
  
  // write string in the txt files
  await writeTxt(data.toString(), fileName);
    
  // read a string again
  dataRead = await readTxt(fileName);
  
  print(dateRead);
}

Todo list #

Benchmarks #

  • [ ] made benchmark on Linux
  • [ ] made benchmark on MacOS
  • [ ] made benchmark on MS Windows

Code implementations #

  • [x] write, read txt (work only in PC)
  • [x] write, read csv (work only in PC)
  • [ ] write, read json (work only in PC)
  • [ ] write, read mongo (work only in PC)
  • [ ] write, read sql like databases (work only in PC)

0.0.1-dev.3 #

  • Plain string read and write functions

0.0.1-dev.2 #

  • SciDart dependency updated to 0.0.1-dev.5

0.0.1-dev.1 #

  • Initial files separated from SciDart main repository

example/scidart_io_example.dart

import 'package:scidart/numdart.dart';
import 'package:scidart_io/scidart_io.dart';

void main() async {
  // read stock_data.csv file in the same directory of the current
  // script
  // the delimiter of this file is ',' but can be any character
  // the reader skip one line in the header of the file and
  // one line at the end of the file
  var data = await readCSV('stock_data.csv',
      delimiter: ',', skipHeader: 1, skipFooter: 1);

  print(data); // show the data

  // generate a 2d array data for test
  var data2 = Array2d([
    Array([1, 2, 3, 4, 5]),
    Array([2, 3, 4, 5, 6]),
    Array([3, 4, 5, 6, 7]),
    Array([4, 5, 6, 7, 8]),
    Array([5, 6, 7, 8, 9]),
  ]);

  // define a file name
  var fileName = 'data_array.csv';

  // save the data in a CSV file
  await writeLinesCSV(data2, fileName);

  // read the same data again and convert to Array2d again
  var data2Read = await readCSV(fileName, convertToArray2d: true);

  print(data2Read); // show the data
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  scidart_io: ^0.0.1-dev.3

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:scidart_io/scidart_io.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
85
Overall:
Weighted score of the above. [more]
47
Learn more about scoring.

We analyzed this package on Nov 7, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.0
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, other

Primary library: package:scidart_io/scidart_io.dart with components: io.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Package is pre-release. (-5 points)

Pre-release versions should be used with caution; their API can change in breaking ways.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.4.0 <3.0.0
path ^1.6.4 1.6.4
scidart ^0.0.1-dev.5 0.0.1-dev.6
Dev dependencies
pedantic ^1.7.0
test ^1.6.0