本文整理汇总了Python中Model.Model.read_csv方法的典型用法代码示例。如果您正苦于以下问题:Python Model.read_csv方法的具体用法?Python Model.read_csv怎么用?Python Model.read_csv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model.Model
的用法示例。
在下文中一共展示了Model.read_csv方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CSVTest
# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import read_csv [as 别名]
class CSVTest(unittest.TestCase):
def setUp(self):
self.model = Model()
def testsetDelimiter(self):
self.model.setDelimiter(",")
self.assertEqual(self.model.delimiter, ",")
def testsetName(self):
self.model.read_csv("data.csv")
self.assertEqual(self.model.name, "data.csv")
def testsetName_None(self):
self.assertRaises(TypeError, self.model.read_csv)
def testsetContent(self):
self.model.setDelimiter(",")
self.model.read_csv("data.csv")
self.assertEqual(
self.model.csv_content, "Year,Make,Model,Length,\n1997,Ford,E350,2.34,\n2000,Mercury,Cougar,2.38,\n"
)
def testsetDelimiter_None(self):
self.assertRaises(TypeError, self.model.setDelimiter)
示例2: loader
# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import read_csv [as 别名]
class loader(QMainWindow):
""" CSV-Module Application
Autor: Thomas Stedronsky
:param parent:
"""
def __init__(self, parent=None):
super().__init__(parent)
self.form = view.Ui_MainWindow()
self.form.setupUi(self)
self.model = Model()
self.model.setDelimiter(',')
self.form.pushButton.clicked.connect(self.clicked)
def get_text_line(self):
self.model.csv_file = self.form.lineEdit.text()
def clicked(self):
self.model.csv_content = ''
self.get_text_line()
self.model.read_csv(self.model.csv_file)
self.form.label_2.setText(self.model.name)
self.form.textEdit.setText(self.model.csv_content)
示例3: Controller
# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import read_csv [as 别名]
#.........这里部分代码省略.........
pass
def undoText_redoText(self):
undo = "Undo"
redo = "Redo"
utext = self.undoStack.undoText()
rtext = self.undoStack.redoText()
if utext:
undo += " \"" + utext + "\""
self.gui.actionUndo.setText(undo)
if rtext:
redo += " \"" + rtext + "\""
self.gui.actionRedo.setText(redo)
def undo(self):
self.undoStack.undo()
self.undoText_redoText()
self.gui.tableView.reset()
def redo(self):
self.undoStack.redo()
self.undoText_redoText()
self.gui.tableView.reset()
def csvfile(self):
"""
Mit dieser Methode wird das ausgewaehlte CSV-File in die Tabelle importiert
:return:
"""
if self.tablemodel.getHeader() == [] and self.tablemodel.getList() == []:
fname = QtGui.QFileDialog.getOpenFileName(self.mwindow, 'Open file...', os.getcwd(), "CSV (*.csv)")[0]
if len(fname) > 0:
self.model.currentfile = fname
datalist, header = self.model.read_csv(fname)
self.update_table(datalist, header)
else:
result = QtGui.QMessageBox.question(QtGui.QWidget(),
'Open',"Moechten Sie wirklich eine neues File öffnen?\n Alle ungespeicherten Daten gehen verloren!",
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No)
if result == QtGui.QMessageBox.Yes:
fname = QtGui.QFileDialog.getOpenFileName(self.mwindow, 'Open file...', os.getcwd(), "CSV (*.csv)")[0]
if len(fname) > 0:
self.model.currentfile = fname
datalist, header = self.model.read_csv(fname)
self.update_table(datalist, header)
else:
pass
def insertintable(self):
"""
Erzeugt eine neuen Zeile (oberhalb der aktuellen Zeile)
:return:
"""
index, amount = self.get_selectedcell()
self.undoStack.beginMacro("Add Row")
self.undoStack.push(InsertCommand(self.tablemodel, index, 1))
self.undoStack.endMacro()
self.undoText_redoText()
def removefromtable(self):
"""
Entfernt eine asugewaehlte Zeile
:return:
"""
index, amount = self.get_selectedcell()