Created
April 20, 2022 13:43
-
-
Save nilsreichardt/941f31ea94f4496ebd39141d67b9dc03 to your computer and use it in GitHub Desktop.
A script to generate a big CSV file with dummy data.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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