本文整理汇总了Python中Orange.data.io.FileFormat.get_reader方法的典型用法代码示例。如果您正苦于以下问题:Python FileFormat.get_reader方法的具体用法?Python FileFormat.get_reader怎么用?Python FileFormat.get_reader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orange.data.io.FileFormat
的用法示例。
在下文中一共展示了FileFormat.get_reader方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_wildcard_extension
# 需要导入模块: from Orange.data.io import FileFormat [as 别名]
# 或者: from Orange.data.io.FileFormat import get_reader [as 别名]
def test_wildcard_extension(self):
self.assertIsInstance(FileFormat.get_reader("t.wild"),
WildcardReader)
self.assertIsInstance(FileFormat.get_reader("t.wild2"),
WildcardReader)
with self.assertRaises(OSError):
FileFormat.get_reader("t.wild2a")
示例2: dragEnterEvent
# 需要导入模块: from Orange.data.io import FileFormat [as 别名]
# 或者: from Orange.data.io.FileFormat import get_reader [as 别名]
def dragEnterEvent(self, event):
"""Accept drops of valid file urls"""
urls = event.mimeData().urls()
if urls:
try:
FileFormat.get_reader(urls[0].toLocalFile())
event.acceptProposedAction()
except IOError:
pass
示例3: _get_reader
# 需要导入模块: from Orange.data.io import FileFormat [as 别名]
# 或者: from Orange.data.io.FileFormat import get_reader [as 别名]
def _get_reader(self):
"""
Returns
-------
FileFormat
"""
if self.source == self.LOCAL_FILE:
path = self.last_path()
if path is None:
return self.NoFileSelected
if self.recent_paths and self.recent_paths[0].file_format:
qname = self.recent_paths[0].file_format
reader_class = class_from_qualified_name(qname)
reader = reader_class(path)
else:
reader = FileFormat.get_reader(path)
if self.recent_paths and self.recent_paths[0].sheet:
reader.select_sheet(self.recent_paths[0].sheet)
return reader
else:
url = self.url_combo.currentText().strip()
if url:
return UrlReader(url)
else:
return self.NoFileSelected
示例4: get_writer_selected
# 需要导入模块: from Orange.data.io import FileFormat [as 别名]
# 或者: from Orange.data.io.FileFormat import get_reader [as 别名]
def get_writer_selected(self):
writer = FileFormat.get_reader(self.type_ext)
ext = self.type_ext + self.compress_ext
if ext not in writer.EXTENSIONS:
self.Error.unsupported_extension()
return None
writer.EXTENSIONS = [ext]
return writer
示例5: _get_reader
# 需要导入模块: from Orange.data.io import FileFormat [as 别名]
# 或者: from Orange.data.io.FileFormat import get_reader [as 别名]
def _get_reader(self):
"""
Returns
-------
FileFormat
"""
if self.source == self.LOCAL_FILE:
reader = FileFormat.get_reader(self.last_path())
if self.recent_paths and self.recent_paths[0].sheet:
reader.select_sheet(self.recent_paths[0].sheet)
return reader
elif self.source == self.URL:
return UrlReader(self.url_combo.currentText())
示例6: load_from_file
# 需要导入模块: from Orange.data.io import FileFormat [as 别名]
# 或者: from Orange.data.io.FileFormat import get_reader [as 别名]
def load_from_file():
filename = self.last_path()
if not filename:
return None, ""
if not os.path.exists(filename):
filename = os.path.basename(filename)
filename = FileFormat.locate(filename, "")
self.information("Loading '{}' from the current directory."
.format(filename))
reader = FileFormat.get_reader(filename)
if isinstance(reader, ExcelReader):
reader.select_sheet(self.xls_sheet)
try:
return load(lambda x: reader.read(), filename)
except Exception as exc:
self.warnings.setText(str(exc))
# Let us not remove from recent files: user may fix them
raise
示例7: test_find_reader
# 需要导入模块: from Orange.data.io import FileFormat [as 别名]
# 或者: from Orange.data.io.FileFormat import get_reader [as 别名]
def test_find_reader(self):
reader = FileFormat.get_reader("some.same_extension")
self.assertIsInstance(reader, SameExtensionPreferred)
示例8: test_usual_extensions
# 需要导入模块: from Orange.data.io import FileFormat [as 别名]
# 或者: from Orange.data.io.FileFormat import get_reader [as 别名]
def test_usual_extensions(self):
self.assertIsInstance(FileFormat.get_reader("t.tab"), TabReader)
self.assertIsInstance(FileFormat.get_reader("t.csv"), CSVReader)
self.assertIsInstance(FileFormat.get_reader("t.pkl"), PickleReader)
with self.assertRaises(OSError):
FileFormat.get_reader("test.undefined_extension")
示例9: is_multisheet_excel
# 需要导入模块: from Orange.data.io import FileFormat [as 别名]
# 或者: from Orange.data.io.FileFormat import get_reader [as 别名]
def is_multisheet_excel(fn):
return len(FileFormat.get_reader(fn).sheets) > 0
示例10: _get_reader
# 需要导入模块: from Orange.data.io import FileFormat [as 别名]
# 或者: from Orange.data.io.FileFormat import get_reader [as 别名]
def _get_reader(rp):
if rp.file_format:
reader_class = class_from_qualified_name(rp.file_format)
return reader_class(rp.abspath)
else:
return FileFormat.get_reader(rp.abspath)