| author | ymh <ymh.work@gmail.com> |
| Tue, 22 Oct 2024 10:01:10 +0200 | |
| changeset 1569 | 455bdfbdd320 |
| parent 1542 | 82b5f22448f6 |
| permissions | -rw-r--r-- |
|
1542
82b5f22448f6
add utilities to manipulate ldt and zoom chats
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1 |
import csv |
|
82b5f22448f6
add utilities to manipulate ldt and zoom chats
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
2 |
import re |
|
82b5f22448f6
add utilities to manipulate ldt and zoom chats
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
3 |
import math |
|
82b5f22448f6
add utilities to manipulate ldt and zoom chats
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
4 |
|
|
82b5f22448f6
add utilities to manipulate ldt and zoom chats
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
5 |
TC_RE = re.compile("(\d{2}) (\d{2}) (\d{2}) ?, ?(\d{2})") |
|
82b5f22448f6
add utilities to manipulate ldt and zoom chats
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
6 |
|
|
82b5f22448f6
add utilities to manipulate ldt and zoom chats
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
7 |
def conver_tc(tc_str): |
|
82b5f22448f6
add utilities to manipulate ldt and zoom chats
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
8 |
m = TC_RE.match(tc_str) |
|
82b5f22448f6
add utilities to manipulate ldt and zoom chats
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
9 |
if not m: |
|
82b5f22448f6
add utilities to manipulate ldt and zoom chats
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
10 |
return math.inf |
|
82b5f22448f6
add utilities to manipulate ldt and zoom chats
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
11 |
return int(m.group(1))*3600000 + int(m.group(2))*60000 + int(m.group(3)) * 1000 + int(m.group(4)) * 10 |
|
82b5f22448f6
add utilities to manipulate ldt and zoom chats
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
12 |
|
|
82b5f22448f6
add utilities to manipulate ldt and zoom chats
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
13 |
if __name__ == "__main__": |
|
82b5f22448f6
add utilities to manipulate ldt and zoom chats
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
14 |
with open('timecodes_webinaire_fcpe.csv') as csvfilein, \ |
|
82b5f22448f6
add utilities to manipulate ldt and zoom chats
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
15 |
open('timecodes_webinaire_fcpe_out.csv', 'w') as csvfileout: |
|
82b5f22448f6
add utilities to manipulate ldt and zoom chats
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
16 |
chap_reader = csv.DictReader(csvfilein, delimiter=';') |
|
82b5f22448f6
add utilities to manipulate ldt and zoom chats
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
17 |
chap_writer = csv.DictWriter(csvfileout, fieldnames=chap_reader.fieldnames, delimiter=';') |
|
82b5f22448f6
add utilities to manipulate ldt and zoom chats
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
18 |
|
|
82b5f22448f6
add utilities to manipulate ldt and zoom chats
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
19 |
chap_writer.writeheader() |
|
82b5f22448f6
add utilities to manipulate ldt and zoom chats
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
20 |
for row in chap_reader: |
|
82b5f22448f6
add utilities to manipulate ldt and zoom chats
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
21 |
if not row['START']: |
|
82b5f22448f6
add utilities to manipulate ldt and zoom chats
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
22 |
next |
|
82b5f22448f6
add utilities to manipulate ldt and zoom chats
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
23 |
row['START'] = conver_tc(row['START']) |
|
82b5f22448f6
add utilities to manipulate ldt and zoom chats
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
24 |
row['END'] = conver_tc(row['END']) |
|
82b5f22448f6
add utilities to manipulate ldt and zoom chats
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
25 |
chap_writer.writerow(row) |