Question: I'm trying to set my progressbar from another class but failed. This is my progressbar the class `Upload`.

```
JProgressBar progressBar = new JProgressBar();
progressBar.setBounds(91, 134, 284, 17);
frame.getContentPane().add(progressBar);

```

I have another class called `Read`. In this class I have a loop that needs to read a file, so I want to set the progress with the iterator `i` from that class. I know that I have to set the minimum and maxium like this:

```
progressBar.setMinimum(0);
progressBar.setMaximum(numRows);

```

And for the value:

```
progressBar.setValue(newValue);

```

How can I set the value for the progressbar so it keeps updating the value of `i`?

Answer: 
I think you want a groupby, grouping strings that don't start with the date and ones that do so the date delimits the groups:

```
l = ['20150406,34.4800,34.8100,34.2300,34.4200,21480500', '2015010,34.5400,34.8900,34.5100,34.6300,14331200'
    , '20150407,34.5400,34.8900,34.5100,34.6300,14331200']
dte = "2015-04-07"

delim = dte.replace("-","") + ","
from itertools import groupby

print([list(v) for k,v in groupby(l,key=lambda x: not x.startswith(delim))])

[['20150406,34.4800,34.8100,34.2300,34.4200,21480500', '2015010,34.5400,34.8900,34.5100,34.6300,14331200'],   ['20150407,34.5400,34.8900,34.5100,34.6300,14331200']]

```

The groupby will keep splitting the data as many times as there are strings the start with the date.
by extend from alecxe answer:
The code can split original list to couple sublist by input date.

```
l = [
...      '20150406,34.4800,34.8100,34.2300,34.4200,21480500',
...      '20160402,34.1,32.8100,33.2300,31.01,22282510',
...      '20150407,34.5400,34.8900,34.5100,34.6300,14331200',
...      '20120101,2.540,14.8201,32.00,30.1311,12331230',
...  '20150407,34.5400,34.8900,34.5100,34.6300,14331200',]

index = [i for i, item in enumerate(l) if item.startswith(d)]
[l[i:j] for i, j in zip([0]+index, index+[None])]

output:
[['20150406,34.4800,34.8100,34.2300,34.4200,21480500', '20160402,34.1,32.8100,33.2300,31.01,22282510'], ['20150407,34.5400,34.8900,34.5100,34.6300,14331200', '20120101,2.540,14.8201,32.00,30.1311,12331230'], ['20150407,34.5400,34.8900,34.5100,34.6300,14331200']]

```