Skip to content

Commit ac1b392

Browse files
authoredOct 4, 2022
Create csvgen.py
This is a simple CSV generator using python
1 parent d740b0e commit ac1b392

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
 

‎csvgen.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#This file generates a CSV file with integer values,
2+
# Use cases: you can use it for eg. input for testing your sroting algorithms and other program inputs when you need to test with large data.
3+
4+
import random as rd;
5+
6+
minNum = 0;
7+
maxNum = 1000; #maximum number in array
8+
lengthOfItems= 500; #this will generate 500 random numbers.
9+
10+
file = open("newFile.csv", "a") # creates a new file named newFile.csv - feel free to edit file name
11+
12+
for i in range(lengthOfItems):
13+
file.write(str(str(rd.randint(minNum,maxNum)) + ","))
14+
15+
file.close()
16+
#note - you will have to split first line at "," and convert to int

0 commit comments

Comments
 (0)
Please sign in to comment.