-
Notifications
You must be signed in to change notification settings - Fork 0
/
File.py
37 lines (26 loc) · 852 Bytes
/
File.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# -*- coding: UTF-8 -*-
import os
def convertSpeToTxt_batch(file_name_list):
for name in file_name_list:
convertSpeToTxt(name)
def convertSpeToTxt(file_name):
fr = open(file_name, 'r')
txt_name = os.path.splitext(file_name)[0] + ".txt"
fw = open(txt_name, 'w')
for i in range(11):
fr.readline()
start_end = fr.readline().split()
end = int(start_end[1]) + 1
for i in range(end):
channel = i + 1
count = int(fr.readline())
fw.write("{}\t{}\n".format(channel, count))
fw.close()
fr.close()
def getSpeFileNameList(directory_name):
file_name = os.listdir(directory_name)
file_name_list = []
for name in file_name:
if (os.path.splitext(name)[1] == ".Spe"):
file_name_list.append(directory_name + "\\" + name)
return file_name_list