Created
October 20, 2022 14:33
-
-
Save sailfish009/7d5d4fa5c930070ac833cd6bb4d368c2 to your computer and use it in GitHub Desktop.
python csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
example = u'00:01:12.788' | |
strs = example.split(":") | |
hours = int(strs[0]) | |
minutes = int(strs[1]) | |
strs2 = strs[2].split(".") | |
seconds = float(strs2[0]) | |
mseconds = float(strs2[1]) | |
miliseconds = int(3600000 * hours + 60000 * minutes + 1000 * seconds + mseconds) | |
print(f'result:{miliseconds}') | |
import csv | |
with open('sample.csv') as file: | |
reader = csv.reader(file) | |
count_changed = -1 | |
start = 0 | |
end = 0 | |
l = [] | |
for row in reader: | |
if row['Count'] != count_changed: | |
if count_changed == -1: | |
start = row['Time'] | |
count_changed = row['Count'] | |
else: | |
end = row['Time'] | |
l.append(end - start) | |
start = end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment