Create a Large file for Test Data Processing using Python

 

Code Example


# Create a Large file for Test Data Processing


This below code will create 1.1GB .txt file


import string
from random import choice


with open("large_data.txt", "w") as fp:
    i = 1
    while i <= 1000000:
        word = (''.join(
                choice(string.ascii_uppercase + string.digits) for _ in range(10)) + "|"
               ) * 100
        fp.write(word[:] + "\n")
        i += 1


Comments

Popular posts from this blog

How To Create .ENV File in Python

How to solve the Liner Equation using Python