Skip to content

Instantly share code, notes, and snippets.

@Zonalds
Forked from momota/generate_L_size_csv.py
Created October 24, 2022 18:46
Show Gist options
  • Save Zonalds/c6afa7b13e0928ec89573b5b86733743 to your computer and use it in GitHub Desktop.
Save Zonalds/c6afa7b13e0928ec89573b5b86733743 to your computer and use it in GitHub Desktop.
Generate a large size of CSV file was filled random values. This script generates around 250MB size of the file. You can adjust two parameters `row` and `col` to generate the file which has desirable size.
import csv
import random
def generate_random_array(row, col):
a = []
for i in range(col):
l = [i]
for j in range(row):
l.append(random.random())
a.append(l)
return a
if __name__ == '__main__':
row = 10
col = 1500000
array = generate_random_array(row, col)
f = open('sample.csv', 'w')
w = csv.writer(f, lineterminator='\n')
w.writerows(array)
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment