PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# help creating filenames and enumerate them
items = [
'900440 A 01.04.2013 00:00:00 250.98',
'900440 B 01.04.2013 01:00:00 250.98',
'900440 C 01.04.2013 02:00:00 250.99',
'900660 D 01.04.2013 03:00:00 250.99',
'900660 E 01.04.2013 04:00:00 240.99',
'900660 F 01.04.2013 05:00:00 260.99',
'900770 I 01.04.2013 04:00:00 250.99',
'900770 J 01.04.2013 05:00:00 251.00',
'900880 K 01.04.2013 06:00:00 251.00']
num = 1
current_id = items[0][0:items[0].index(' ')]
for item in items:
if item.split()[0] == current_id: # if no new item
with open(f'{item.split()[0]}_{num}.csv', 'w') as my_file:
my_file.write(item)
else: # if item has changed
num = 1
with open(f'{item.split()[0]}_{num}.csv', 'w') as my_file:
my_file.write(item)
current_id = item.split()[0]
num += 1
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run