I am trying to generate random data with range of specific latitude and longitude. The code below executes with no errors and also generates output but not fully what I am expecting.
Program:
import random
import sys
import math
latitude = 19.99
longitude = 73.78
output_file = 'filename'
def generate_random_data():
with open(output_file, 'w') as output:
hex1 = '%012X' % random.randint(0,100)
flt = float(random.randint(0,100))
latitude = math.acos(random.random() * 2 - 1)
longitude = random.random() * math.pi * 2
output.write('%s %.1f %.6f %.6f \n' % (hex1.lower(), flt, longitude, latitude))
if __name__ == '__main__':
generate_random_data()
The above code runs but gives only one row (which could be indentation problem) But this does not give me random lat
& long
in required Geo location as mentioned above.
Output generated:
000000000020 95.0 3.929691 1.749931
Output Expected:
000000000020 95.0 19.999691 73.799931
And this generates only one
row where as I am trying to have million
rows