本文整理匯總了Python中csv.excel_tab方法的典型用法代碼示例。如果您正苦於以下問題:Python csv.excel_tab方法的具體用法?Python csv.excel_tab怎麽用?Python csv.excel_tab使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類csv
的用法示例。
在下文中一共展示了csv.excel_tab方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_test_data
# 需要導入模塊: import csv [as 別名]
# 或者: from csv import excel_tab [as 別名]
def get_test_data(fn, col_name, f0_base, sample):
"""Get frame and col_name data from output file named by f0_base and sample.
That is, given fn, return the data produced from that input file
(the filenames appear in the first column), taking the data from the output
file whose name has f0_base (sf0, pf0, shrf0, strf0) and sample (1ms, 9seg)
in it. Return a list of tuples consisting of the frame offset (t_ms) and
the data from the column named by col_name, converted to floats.
"""
in_name = os.path.splitext(os.path.basename(fn))[0]
fn = os.path.join(data_path, 'output-' + f0_base + '-' + sample + '.txt')
res = []
with open(fn) as f:
c = csv.DictReader(f, dialect=csv.excel_tab)
for row in c:
if row['Filename'].startswith(in_name):
res.append((float(row['t_ms']), float(row[col_name])))
return res
示例2: __init__
# 需要導入模塊: import csv [as 別名]
# 或者: from csv import excel_tab [as 別名]
def __init__(self, infile, **kwargs):
blast_file = open(infile, 'r')
self.reader = csv.reader(blast_file, dialect=csv.excel_tab)
示例3: __init__
# 需要導入模塊: import csv [as 別名]
# 或者: from csv import excel_tab [as 別名]
def __init__(self, infile, **kwargs):
blast_file = open(infile, 'r')
self.reader = csv.reader(blast_file, dialect=csv.excel_tab)
示例4: convert
# 需要導入模塊: import csv [as 別名]
# 或者: from csv import excel_tab [as 別名]
def convert(input, out):
if os.path.exists(out):
raise ValueError("Output file already exists")
reader = csv.reader(open(input, 'rU'), dialect=csv.excel_tab)
writer = csv.writer(open(out, "wb+"), dialect="excel")
for row in reader:
writer.writerow(row)
示例5: get_db
# 需要導入模塊: import csv [as 別名]
# 或者: from csv import excel_tab [as 別名]
def get_db(cls, filename):
# 駅データのcsvを読み込んでキャッシュする
if cls.db == None:
cls.db = []
for row in csv.reader(open(filename, 'rU'), delimiter=',', dialect=csv.excel_tab):
cls.db.append(cls(row))
return cls.db
示例6: _read_tsv_file
# 需要導入模塊: import csv [as 別名]
# 或者: from csv import excel_tab [as 別名]
def _read_tsv_file(self, file_like, **kwargs):
return self._read_csv_file(file_like, dialect=csv.excel_tab, **kwargs)
示例7: tsvb
# 需要導入模塊: import csv [as 別名]
# 或者: from csv import excel_tab [as 別名]
def tsvb(lis, columns=[], encoding="utf-8"):
"""bytes -> list"""
return csvb(lis, columns=columns, dialect=csv.excel_tab, encoding=encoding)
示例8: untsvb
# 需要導入模塊: import csv [as 別名]
# 或者: from csv import excel_tab [as 別名]
def untsvb(bytes, columns=[], encoding="utf-8"):
"""bytes -> list"""
return uncsvb(bytes, columns=columns, dialect=csv.excel_tab, encoding=encoding)
示例9: dtsvb
# 需要導入模塊: import csv [as 別名]
# 或者: from csv import excel_tab [as 別名]
def dtsvb(lis, encoding="utf-8"):
"""bytes -> list"""
return dcsvb(lis, dialect=csv.excel_tab, encoding=encoding)
示例10: undtsvb
# 需要導入模塊: import csv [as 別名]
# 或者: from csv import excel_tab [as 別名]
def undtsvb(bytes, encoding="utf-8"):
"""bytes -> list"""
return undcsvb(bytes, dialect=csv.excel_tab, encoding=encoding)
示例11: bootstrap_query_file
# 需要導入模塊: import csv [as 別名]
# 或者: from csv import excel_tab [as 別名]
def bootstrap_query_file(input_file, output_file, nlp, **kwargs):
"""
Apply predicted annotations to a file of text queries
Args:
input_file (str): filename of queries to be processed
output_file (str or None): filename for processed queries
nlp (NaturalLanguageProcessor): an application's NLP with built models
kwargs (dict): A dictionary of additional args
"""
show_confidence = kwargs.get("confidence")
with open(output_file, "w") if output_file else sys.stdout as csv_file:
field_names = ["query"]
if not kwargs.get("no_domain"):
field_names.append("domain")
if show_confidence:
field_names.append("domain_conf")
if not kwargs.get("no_intent"):
field_names.append("intent")
if show_confidence:
field_names.append("intent_conf")
if show_confidence and not kwargs.get("no_entity"):
field_names.append("entity_conf")
if show_confidence and not kwargs.get("no_role"):
field_names.append("role_conf")
csv_output = csv.DictWriter(csv_file, field_names, dialect=csv.excel_tab)
csv_output.writeheader()
for raw_query in mark_down_file(input_file):
proc_query = nlp.process_query(nlp.create_query(raw_query), verbose=True)
csv_row = bootstrap_query_row(proc_query, show_confidence, **kwargs)
csv_output.writerow(csv_row)
示例12: question_uploader_2
# 需要導入模塊: import csv [as 別名]
# 或者: from csv import excel_tab [as 別名]
def question_uploader_2(root_path, file_name="questions.csv"):
"""
This is the uploader for the second data set collected by Isaac
The root path contains "question.csv" file.
headers are:
image name, text, choice 1, choice 2, ... , choice 5, answer, ... , is multiple choice
:param root_path:
:return:
"""
file_path = os.path.join(root_path, file_name)
flag = False
with open(file_path, 'rU') as csvfile:
reader = csv.reader(csvfile, delimiter=',', dialect=csv.excel_tab)
reader.next()
for row in reader:
image_name = row[0]
question_text = row[1]
choices = row[2:7]
answer = row[7]
is_problematic = row[9] == '1'
has_choices = row[10] == '1'
has_answer = row[11] == '1'
"""
if image_name == "0510.png":
flag = True
if not flag:
continue
"""
if is_problematic:
continue
if has_choices:
answer = answer.split(" ")[1]
else:
choices = []
image_path = os.path.join(root_path, image_name)
geoserver_interface.upload_question(question_text, image_path, choices, answer)
print(image_name)