Spaces:
Runtime error
Runtime error
Fix timestamp
Browse files
app.py
CHANGED
|
@@ -2,12 +2,19 @@ import gradio as gr
|
|
| 2 |
import pandas as pd
|
| 3 |
import re
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
def csv_to_dict(df):
|
| 13 |
df = df.fillna('')
|
|
@@ -46,7 +53,7 @@ def process_files(files):
|
|
| 46 |
return "Please upload at least 2 files."
|
| 47 |
|
| 48 |
# 根据文件名中的时间戳进行排序
|
| 49 |
-
files_sorted = sorted(files, key=
|
| 50 |
|
| 51 |
result = []
|
| 52 |
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
import re
|
| 4 |
|
| 5 |
+
# 提取文件名中的所有数字作为时间戳
|
| 6 |
+
def extract_timestamps(file_name):
|
| 7 |
+
# 使用正则表达式提取所有的数字
|
| 8 |
+
timestamps = re.findall(r'(\d+)', file_name)
|
| 9 |
+
# 将这些数字转换为整数,返回列表
|
| 10 |
+
return [int(ts) for ts in timestamps]
|
| 11 |
+
|
| 12 |
+
# 根据提取的时间戳列表排序
|
| 13 |
+
def sort_by_timestamps(file_name):
|
| 14 |
+
# 提取所有时间戳,并按自然顺序进行排序
|
| 15 |
+
timestamps = extract_timestamps(file_name)
|
| 16 |
+
# 返回时间戳中的最小值作为排序的主键
|
| 17 |
+
return timestamps
|
| 18 |
|
| 19 |
def csv_to_dict(df):
|
| 20 |
df = df.fillna('')
|
|
|
|
| 53 |
return "Please upload at least 2 files."
|
| 54 |
|
| 55 |
# 根据文件名中的时间戳进行排序
|
| 56 |
+
files_sorted = sorted(files, key=sort_by_timestamps)
|
| 57 |
|
| 58 |
result = []
|
| 59 |
|