Repository: gunnarmorling/1brc (language: java)

Issue:
`create_measurements.py` doesn't show correct progress bar
Launching `src/main/python/create_measurements.py`  outputs wrong progress bar

```
$ python create_measurements.py 1_000_000_000
Estimated max file size is:  27.9 GiB.
True size is probably much smaller (around half).
Building test data...
[                                                  ] 0%
Test data successfully written to 1brc/data/measurements.txt
Actual file size:  14.7 GiB
Elapsed time: 24 minutes 41 seconds
Test data build complete.
```

It always stays at 0% even when file is generated.


Discussion / hints:

Fix patch:
diff --git a/src/main/python/create_measurements.py b/src/main/python/create_measurements.py
index 26ec768a0..6d45f6055 100755
--- a/src/main/python/create_measurements.py
+++ b/src/main/python/create_measurements.py
@@ -111,21 +111,23 @@ def build_test_data(weather_station_names, num_rows_to_create):
     hottest_temp = 99.9
     station_names_10k_max = random.choices(weather_station_names, k=10_000)
     batch_size = 10000 # instead of writing line by line to file, process a batch of stations and put it to disk
-    progress_step = max(1, (num_rows_to_create // batch_size) // 100)
+    chunks = num_rows_to_create // batch_size
     print('Building test data...')
 
     try:
         with open("../../../data/measurements.txt", 'w') as file:
-            for s in range(0,num_rows_to_create // batch_size):
+            progress = 0
+            for chunk in range(chunks):
                 
                 batch = random.choices(station_names_10k_max, k=batch_size)
                 prepped_deviated_batch = '\n'.join([f"{station};{random.uniform(coldest_temp, hottest_temp):.1f}" for station in batch]) # :.1f should quicker than round on a large scale, because round utilizes mathematical operation
                 file.write(prepped_deviated_batch + '\n')
                 
                 # Update progress bar every 1%
-                if s % progress_step == 0 or s == num_rows_to_create - 1:
-                    sys.stdout.write('\r')
-                    sys.stdout.write("[%-50s] %d%%" % ('=' * int((s + 1) / num_rows_to_create * 50), (s + 1) / num_rows_to_create * 100))
+                if (chunk + 1) * 100 // chunks != progress:
+                    progress = (chunk + 1) * 100 // chunks
+                    bars = '=' * (progress // 2)
+                    sys.stdout.write(f"\r[{bars:<50}] {progress}%")
                     sys.stdout.flush()
         sys.stdout.write('\n')
     except Exception as e:


Test patch: