Spaces:
Runtime error
Runtime error
Huhujingjing
commited on
Commit
·
a33afb6
1
Parent(s):
3f7a930
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ import os
|
|
3 |
import numpy as np
|
4 |
import pandas as pd
|
5 |
from scipy.signal import find_peaks
|
6 |
-
|
7 |
|
8 |
def process_text(file):
|
9 |
|
@@ -11,11 +11,19 @@ def process_text(file):
|
|
11 |
x = [] # x值
|
12 |
y = [] # y值
|
13 |
|
14 |
-
filename = file.name
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
# 读取文件内容
|
18 |
-
with open(
|
19 |
lines = f.readlines()
|
20 |
data = []
|
21 |
for line in lines:
|
|
|
3 |
import numpy as np
|
4 |
import pandas as pd
|
5 |
from scipy.signal import find_peaks
|
6 |
+
from werkzeug.utils import secure_filename
|
7 |
|
8 |
def process_text(file):
|
9 |
|
|
|
11 |
x = [] # x值
|
12 |
y = [] # y值
|
13 |
|
14 |
+
filename = secure_filename(file.name)
|
15 |
+
upload_path = "./uploads/"
|
16 |
+
if not os.path.exists(upload_path):
|
17 |
+
os.mkdir(upload_path)
|
18 |
+
|
19 |
+
file_path = upload_path + filename
|
20 |
+
file.save(file_path)
|
21 |
+
|
22 |
+
name = file.name.split(".")[0]
|
23 |
+
target_path = upload_path + f"{name}.csv" # 目标路径
|
24 |
|
25 |
# 读取文件内容
|
26 |
+
with open(file_path, 'r', encoding='utf-8') as f:
|
27 |
lines = f.readlines()
|
28 |
data = []
|
29 |
for line in lines:
|