Last active
January 25, 2016 14:44
-
-
Save lfyzjck/6b7b5984b2df6d25ff21 to your computer and use it in GitHub Desktop.
simple script to generate random matrix and export to csv
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 random | |
import csv | |
def export_matrix(box, output_file='matrix.csv'): | |
with open(output_file, 'w') as f: | |
writer = csv.writer(f, delimiter=',') | |
for line in box: | |
writer.writerow(line) | |
def random_matrix(rows, cols, max_number=10000): | |
return [[random.randint(0, max_number) for j in range(rows)] for i in range(cols)] | |
if __name__ == '__main__': | |
box = random_matrix(20, 100) | |
export_matrix(box) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment