Skip to content

Instantly share code, notes, and snippets.

@nilsreichardt
Created April 20, 2022 13:43
Show Gist options
  • Save nilsreichardt/941f31ea94f4496ebd39141d67b9dc03 to your computer and use it in GitHub Desktop.
Save nilsreichardt/941f31ea94f4496ebd39141d67b9dc03 to your computer and use it in GitHub Desktop.
A script to generate a big CSV file with dummy data.
import 'dart:io';
import 'dart:math';
void main() {
final titles = List.generate(12, (i) => '$i');
// Generate data
final data = [
titles,
for (int i = 0; i < 200000; i++)
List.generate(titles.length, (_) => generateRandomString(20))
];
// Write to csv file
File('big_csv_file.csv')
.writeAsStringSync(data.map((row) => row.join(',')).join('\n'));
}
String generateRandomString(int len) {
return String.fromCharCodes(
List.generate(len, (index) => Random().nextInt(33) + 89));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment