Huhujingjing commited on
Commit
a33afb6
·
1 Parent(s): 3f7a930

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
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.split(".")[0]
15
- target_path = f"{filename}.csv" # 目标路径
 
 
 
 
 
 
 
 
16
 
17
  # 读取文件内容
18
- with open(file, 'r', encoding='utf-8') as f:
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: