import csv
import os
import glob
# Your folder location where the input files are saved.
name_of_folder = '...'
output_filename = 'output.txt'
input_files = glob.glob(os.path.join(name_of_folder, '*.txt'))
with open(os.path.join(name_of_folder, output_filename), 'w') as file_out:
headers_read = False
for input_file in input_files:
if input_file == os.path.join(name_of_folder, output_filename):
# If the output file is in the list of input files, ignore it.
continue
with open(input_file, 'r') as fin:
reader = csv.reader(fin)
if not headers_read:
# Read column headers just once
headers = reader.next()[0].split()
headers = headers[2:4] + [headers[9]]
file_out.write("\t".join(headers + ['\n'])) # Zero based indexing.
headers_read = True
else:
_ = reader.next() # Ignore header row.
for line in reader:
if line: # Ignore blank lines.
line_out = line[0].split()
file_out.write("\t".join(line_out[2:4] + [line_out[9]] + ['\n']))
>>> !cat output.txt
gene locus log2(fold_change)
ZZ 1:1 0
ZZ 1:1 0
在本规范中,我有两种不同的输出,但写作方式相同吗?
x1的唯一区别是function test();而x2是test();只有没有关键字“功能”你可以向我解释为什么我有两个不同的输出?
答案 0 :(得分:3)
这声明/定义函数test
:
function test(){
echo"x1 is: $x";
}
这会调用函数test
:
test();
然后在这个例子中,echo
发生在任何函数之外。
答案 1 :(得分:1)
您正在第一个中定义一个函数。
您正在调用第二个函数,然后调用echo "x2 is: $x"
。