def test_row_in_file_filter(self): r1 = pe.load("testcsv1.csv") r2 = pe.load("testcsv2.csv") r2.filter(pe.filters.ColumnFilter([2])) r1.filter(pe.filters.RowInFileFilter(r2)) result = [1, 'a', 2, 'b', 3, 'c', 8, 'h'] actual = pe.utils.to_array(r1.enumerate()) self.assertEqual(result, actual)
def test_row_value_filter(self): r1 = pe.load("testcsv1.csv") r2 = pe.load("testcsv2.csv") filter_func = lambda array: r2.contains((lambda row: array[0] == row[0] and array[1] == row[1])) r1.filter(pe.filters.RowValueFilter(filter_func).invert()) result = ['1', 'a', '2', 'b', '3', 'c', '8', 'h'] actual = pe.utils.to_array(r1.enumerate()) assert result == actual
def test_row_in_file_filter(self): r1 = pe.load("testcsv1.csv") r2 = pe.load("testcsv2.csv") r2.filter(pe.filters.ColumnFilter([2])) r1.filter(pe.filters.RowInFileFilter(r2)) result = ['1', 'a', '2', 'b', '3', 'c', '8', 'h'] actual = pe.utils.to_array(r1.enumerate()) assert result == actual
def test_row_in_file_filter(self): r1 = pe.load("testcsv1.csv") r2 = pe.load("testcsv2.csv") r2.filter(pe.sheets.filters.ColumnFilter([2])) r1.filter(pe.sheets.filters.RowInFileFilter(r2)) result = [1, 'a', 2, 'b', 3, 'c', 8, 'h'] actual = pe.utils.to_array(r1.enumerate()) self.assertEqual(result, actual)
def test_pyexcel_issue_5(self): """pyexcel issue #5 datetime is not properly parsed """ s = pe.load( os.path.join("tests", "test-fixtures", "test-date-format.xls")) s.save_as("issue5.xlsx") s2 = pe.load("issue5.xlsx") assert s[0, 0] == datetime.datetime(2015, 11, 11, 11, 12, 0) assert s2[0, 0] == datetime.datetime(2015, 11, 11, 11, 12, 0)
def test_row_value_filter(self): r1 = pe.load("testcsv1.csv") r2 = pe.load("testcsv2.csv") def filter_func(array): def func(row): return array[0] == row[0] and array[1] == row[1] return r2.contains(func) r1.filter(pe.filters.RowValueFilter(filter_func).invert()) result = [1, 'a', 2, 'b', 3, 'c', 8, 'h'] actual = pe.utils.to_array(r1.enumerate()) self.assertEqual(result, actual)
def test_pyexcel_issue_5(self): """pyexcel issue #5 datetime is not properly parsed """ s = pe.load( os.path.join("tests", "test-fixtures", "test-date-format.xls") ) s.save_as("issue5.xlsx", library="pyexcel-libxlsxw") s2 = pe.load("issue5.xlsx") eq_(s[0, 0], datetime.datetime(2015, 11, 11, 11, 12, 0)) eq_(s2[0, 0], datetime.datetime(2015, 11, 11, 11, 12, 0))
def test_pyexcel_issue_5(self): """pyexcel issue #5 datetime is not properly parsed """ s = pe.load(os.path.join("tests", "test-fixtures", "test-date-format.xls")) s.save_as("issue5.xlsx") s2 = pe.load("issue5.xlsx") print(s[0,0]) assert s[0,0] == datetime.datetime(2015, 11, 11, 11, 12, 0) assert s2[0,0] == datetime.datetime(2015, 11, 11, 11, 12, 0)
def test_row_value_filter(self): r1 = pe.load("testcsv1.csv") r2 = pe.load("testcsv2.csv") def filter_func(array): def func(row): return array[0] == row[0] and array[1] == row[1] return r2.contains(func) r1.filter(pe.sheets.filters.RowValueFilter(filter_func).invert()) result = [1, 'a', 2, 'b', 3, 'c', 8, 'h'] actual = pe.utils.to_array(r1.enumerate()) self.assertEqual(result, actual)
def test_pyexcel_issue_5(): """pyexcel issue #5 datetime is not properly parsed """ s = pe.load(get_fixture("test-date-format.xls")) assert s[0, 0] == datetime.datetime(2015, 11, 11, 11, 12, 0)
def process_erke_triage(rf_name, wf_name, clinic_folder): """ 加载Excel文件 :param rf_name 读取文件 :param wf_name 写入文件 :param clinic_folder 科室文件夹 :return: """ print "\t读取文件: %s" % rf_name print "\t写入文件: %s" % wf_name print "\t科室文件夹: %s" % clinic_folder create_file(wf_name) excel_data = pyexcel.load(read_file) # 读取文件 lines = excel_data.get_internal_array() clinic_words_trie = load_clinic_words_trie(clinic_folder) # 处理科室文件夹 workbook = xlsxwriter.Workbook(wf_name) # 创建Excel worksheet = workbook.add_worksheet() # 添加Sheet worksheet.write_row( 0, 0, lines[1] + [u'第一细分', u'词数', u'匹配词', u'第二细分', u'词数', u'匹配词']) count = 1 for index in range(2, len(lines)): problem_info = unicode(lines[index][1]) data_line = lines[index] + parse_problem_info(problem_info, clinic_words_trie) worksheet.write_row(count, 0, data_line) count += 1 if count % 10000 == 0: print "\t count %s" % count print "写入行数: %s" % count
def choose(): #open xls link_file = dg.askopenfilename(type="xls") sheet = exel.load("{}".format(link_file)) #mysql _host = "localhost" _passoword = "" _user = "******" _db = "sgda" conn = mysql.Connection(host=_host, db=_db, password=_passoword, user=_user) exe = conn.cursor() exe.execute( """CREATE TABLE main(%s VARCHAR(32) DEFAULT '' not null,%s INT DEFAULT '0' ,%s INT DEFAULT '0' ,%s INT DEFAULT '0' ,%s INT DEFAULT '0' ,%s INT DEFAULT '0',%s INT DEFAULT '0') """ % ("name", "price", "numper_i_buy", "numper_of_fragment_in_unit", "numper_unit_sold", "numper_unit_fragment_sold", "total")) conn.commit() print("the table created") for n in sheet.row_range(): exe.execute(""" INSERT INTO main(name) VALUES("%s")""" % (sheet[n, 0])) conn.commit() for n in sheet.row_range(): exe.execute(""" UPDATE `main` SET `price`="%s" WHERE `name`="%s" """ % (sheet[n, 1], sheet[n, 0])) conn.commit() exe.execute( """CREATE TABLE sell_today(%s VARCHAR(32) DEFAULT '' not null,%s INT DEFAULT '0' ,%s INT DEFAULT '0' ,%s INT DEFAULT '0',%s VARCHAR(32) DEFAULT '' not null,%s VARCHAR(32) DEFAULT '' not null,%s INT DEFAULT '0') """ % ("name", "unit", "fregment", "price", "date", "bill_link", "bill_numper")) conn.commit() conn.close()
def test_pyexcel_issue_8_with_memory_file(self): """pyexcel issue #8 formular got lost """ tmp_file = "issue_8_save_as.xlsx" f = open(os.path.join("tests", "test-fixtures", "test8.xlsx"), "rb") s = pe.load_from_memory('xlsx', f.read()) s.save_as(tmp_file) s2 = pe.load(tmp_file) assert str(s) == str(s2) content = dedent(""" Sheet Name: CNY +----------+----------+------+---+--------+ | 01/09/13 | 02/09/13 | 1000 | 5 | 13.890 | +----------+----------+------+---+--------+ | 02/09/13 | 03/09/13 | 2000 | 6 | 33.330 | +----------+----------+------+---+--------+ | 03/09/13 | 04/09/13 | 3000 | 7 | 58.330 | +----------+----------+------+---+--------+""").strip("\n") assert str(s2) == content os.unlink(tmp_file)
def main(base_dir): sheet = pe.load(os.path.join(base_dir, "tutorial_datatype_01.xls"), name_columns_by_row=0) print(sheet.to_dict()) #{u'userid': [10120.0, 10121.0, 10122.0], u'name': [u'Adam', u'Bella', u'Cedar']} sheet.column.format(0, str) print(sheet.to_dict())
def test_pyexcel_issue_8_with_memory_file(self): """pyexcel issue #8 formular got lost """ tmp_file = "issue_8_save_as.xlsx" f = open(os.path.join("tests", "test-fixtures", "test8.xlsx"), "rb") s = pe.load_from_memory('xlsx', f.read()) s.save_as(tmp_file) s2 = pe.load(tmp_file) self.assertEqual(str(s), str(s2)) content = dedent(""" CNY: +----------+----------+------+---+-------+ | 01/09/13 | 02/09/13 | 1000 | 5 | 13.89 | +----------+----------+------+---+-------+ | 02/09/13 | 03/09/13 | 2000 | 6 | 33.33 | +----------+----------+------+---+-------+ | 03/09/13 | 04/09/13 | 3000 | 7 | 58.33 | +----------+----------+------+---+-------+""").strip("\n") self.assertEqual(str(s2), content) os.unlink(tmp_file)
def test_odd_row_filter(self): r = pe.load(self.test_tuple) r.filter(pe.filters.OddRowFilter()) assert r.number_of_rows() == 1 assert r.number_of_columns() == 4 result = [5, 6, 7, 8] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def test_single_column_filter_double_invert(self): r = pe.load((self.file_type, self.testfile.getvalue())) r.filter(pe.filters.SingleColumnFilter(0).invert().invert()) assert r.number_of_rows() == 3 assert r.number_of_columns() == 3 result = [2, 3, 4, 6, 7, 8, 10, 11, 12] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def test_single_column_filter_double_invert(self): r = pe.load((self.file_type, self.testfile.getvalue())) r.filter(pe.sheets.filters.SingleColumnFilter(0).invert().invert()) assert r.number_of_rows() == 3 assert r.number_of_columns() == 3 result = [2, 3, 4, 6, 7, 8, 10, 11, 12] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def test_column_filter_with_invalid_indices(self): r = pe.load((self.file_type, self.testfile.getvalue())) r.filter(pe.sheets.filters.ColumnFilter([11, -1])) assert r.number_of_rows() == 3 assert r.number_of_columns() == 4 result = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def test_single_row_filter(self): r = pe.load((self.file_type, self.testfile.getvalue())) r.filter(pe.sheets.filters.SingleRowFilter(1)) assert r.number_of_rows() == 2 assert r.number_of_columns() == 4 result = [1, 2, 3, 4, 9, 10, 11, 12] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def test_odd_row_filter(self): r = pe.load((self.file_type, self.testfile.getvalue())) r.filter(pe.filters.OddRowFilter()) assert r.number_of_rows() == 1 assert r.number_of_columns() == 4 result = [5, 6, 7, 8] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def test_odd_row_filter(self): r = pe.load(self.test_tuple) r.filter(pe.sheets.filters.OddRowFilter()) assert r.number_of_rows() == 1 assert r.number_of_columns() == 4 result = [5, 6, 7, 8] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def main(base_dir): # "example.csv","example.ods","example.xls", "example.xlsm" spreadsheet = pe.load(os.path.join(base_dir, "example.xlsx")) # columns() returns column based iterator, meaning it can be iterated # column by column for value in spreadsheet.columns(): print(value)
def test_write_and_read(self): data = [[11, 112], [312, 534]] sheet = pe.Sheet(data) sheet.save_as(self.testfile) sheet2 = pe.load(self.testfile) sheet2.format(int) result = sheet2.to_array() assert data == result
def test_row_filter_with_invalid_indices(self): r = pe.load(self.test_tuple) r.filter(pe.filters.RowFilter([11, -1])) assert r.number_of_rows() == 3 assert r.number_of_columns() == 4 result = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def test_odd_column_filter(self): r = pe.load((self.file_type, self.testfile.getvalue())) r.filter(pe.filters.OddColumnFilter()) assert r.number_of_rows() == 3 assert r.number_of_columns() == 2 result = [2, 4, 6, 8, 10, 12] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def test_even_column_filter(self): r = pe.load(self.test_tuple) r.filter(pe.sheets.filters.EvenColumnFilter()) assert r.number_of_rows() == 3 assert r.number_of_columns() == 2 result = [1, 3, 5, 7, 9, 11] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def test_even_column_filter(self): r = pe.load((self.file_type, self.testfile.getvalue())) r.filter(pe.filters.EvenColumnFilter()) assert r.number_of_rows() == 3 assert r.number_of_columns() == 2 result = [1, 3, 5, 7, 9, 11] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def test_odd_column_filter(self): r = pe.load(self.test_tuple) r.filter(pe.sheets.filters.OddColumnFilter()) assert r.number_of_rows() == 3 assert r.number_of_columns() == 2 result = [2, 4, 6, 8, 10, 12] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def test_row_filter_with_invalid_indices(self): r = pe.load(self.test_tuple) r.filter(pe.sheets.filters.RowFilter([11, -1])) assert r.number_of_rows() == 3 assert r.number_of_columns() == 4 result = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def test_even_row_filter(self): r = pe.load(self.test_tuple) r.filter(pe.filters.EvenRowFilter()) assert r.number_of_rows() == 2 assert r.number_of_columns() == 4 result = [1, 2, 3, 4, 9, 10, 11, 12] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def main(base_dir): # "example.csv","example.ods","example.xls", "example.xlsm" spreadsheet = pe.load(os.path.join(base_dir,"example.xlsx")) # columns() returns column based iterator, meaning it can be iterated # column by column for value in spreadsheet.columns(): print(value)
def test_odd_column_filter(self): r = pe.load(self.test_tuple) r.filter(pe.filters.OddColumnFilter()) assert r.number_of_rows() == 3 assert r.number_of_columns() == 2 result = [2, 4, 6, 8, 10, 12] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def test_single_row_filter(self): r = pe.load((self.file_type, self.testfile.getvalue())) r.filter(pe.filters.SingleRowFilter(1)) assert r.number_of_rows() == 2 assert r.number_of_columns() == 4 result = [1, 2, 3, 4, 9, 10, 11, 12] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def test_column_filter_with_invalid_indices(self): r = pe.load((self.file_type, self.testfile.getvalue())) r.filter(pe.filters.ColumnFilter([11, -1])) assert r.number_of_rows() == 3 assert r.number_of_columns() == 4 result = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def test_even_column_filter(self): r = pe.load(self.test_tuple) r.filter(pe.filters.EvenColumnFilter()) assert r.number_of_rows() == 3 assert r.number_of_columns() == 2 result = [1, 3, 5, 7, 9, 11] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def test_even_row_filter(self): r = pe.load(self.test_tuple) r.filter(pe.sheets.filters.EvenRowFilter()) assert r.number_of_rows() == 2 assert r.number_of_columns() == 4 result = [1, 2, 3, 4, 9, 10, 11, 12] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def test_pyexcel_issue_5(self): """pyexcel issue #5 datetime is not properly parsed """ s = pe.load(os.path.join("tests", "test-fixtures", "test-date-format.xls")) assert s[0, 0] == datetime.datetime(2015, 11, 11, 11, 12, 0)
def test_column_index_filter(self): r = pe.load(self.test_tuple) def test_func(x): return x in [0, 2] r.add_filter(pe.filters.ColumnIndexFilter(test_func)) assert r.number_of_rows() == 3 assert r.number_of_columns() == 2 result = [2, 4, 6, 8, 10, 12] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def test_pyexcel_issue_5(): """pyexcel issue #5 datetime is not properly parsed """ s = pe.get_sheet(file_name=get_fixtures("test-date-format.xls")) s.save_as("issue5.xlsx") s2 = pe.load("issue5.xlsx") assert s[0, 0] == datetime.datetime(2015, 11, 11, 11, 12, 0) assert s2[0, 0] == datetime.datetime(2015, 11, 11, 11, 12, 0)
def test_row_index_filter(self): r = pe.load(self.test_tuple) def filter_func(x): return x in [1] r.add_filter(pe.filters.RowIndexFilter(filter_func)) assert r.number_of_rows() == 2 assert r.number_of_columns() == 4 result = [1, 2, 3, 4, 9, 10, 11, 12] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def test_two_filters(self): r = pe.load((self.file_type, self.testfile.getvalue())) f1 = pe.filters.OddRowFilter() f2 = pe.filters.OddColumnFilter() r.add_filter(f1) r.add_filter(f2) assert r.number_of_columns() == 2 assert r.number_of_rows() == 1 result = [6, 8] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def test_two_filters(self): r = pe.load((self.file_type, self.testfile.getvalue())) f1 = pe.sheets.filters.OddRowFilter() f2 = pe.sheets.filters.OddColumnFilter() r.add_filter(f1) r.add_filter(f2) assert r.number_of_columns() == 2 assert r.number_of_rows() == 1 result = [6, 8] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def main(base_dir): sheet = pe.load(os.path.join(base_dir, "tutorial_datatype_02.xls")) print(sheet.array) def cleanse_func(v): v = v.replace(" ", "") v = v.rstrip().strip() return v sheet.map(cleanse_func) print(sheet.array)
def test_row_index_filter(self): r = pe.load(self.test_tuple) def filter_func(x): return x in [1] r.add_filter(pe.sheets.filters.RowIndexFilter(filter_func)) assert r.number_of_rows() == 2 assert r.number_of_columns() == 4 result = [1, 2, 3, 4, 9, 10, 11, 12] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def main(base_dir): sheet = pe.load(os.path.join(base_dir, "tutorial_datatype_02.xls")) print(sheet.to_array()) def cleanse_func(v): v = v.replace(" ", "") v = v.rstrip().strip() return v sf = pe.SheetFormatter(cleanse_func) sheet.add_formatter(sf) print(sheet.to_array())
def test_column_index_filter(self): r = pe.load(self.test_tuple) def test_func(x): return x in [0, 2] r.add_filter(pe.sheets.filters.ColumnIndexFilter(test_func)) assert r.number_of_rows() == 3 assert r.number_of_columns() == 2 result = [2, 4, 6, 8, 10, 12] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def main(base_dir): sheet = pe.load(os.path.join(base_dir, "tutorial_datatype_02.ods")) print(sheet.to_array()) def cleanse_func(v): v = v.replace(" ", "") v = v.rstrip().strip() return v sf = pe.SheetFormatter(cleanse_func) sheet.add_formatter(sf) print(sheet.to_array())
def test_remove_filter(self): r = pe.load((self.file_type, self.testfile.getvalue())) f = pe.filters.OddRowFilter() r.add_filter(f) assert r.number_of_rows() == 1 assert r.number_of_columns() == 4 result = [5, 6, 7, 8] actual = pe.utils.to_array(r.enumerate()) assert result == actual r.remove_filter(f) result = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def test_pyexcel_issue_8_with_physical_file(self): """pyexcel issue #8 formular got lost """ tmp_file = "issue_8_save_as.xlsx" s = pe.load(os.path.join("tests", "test-fixtures", "test8.xlsx")) s.save_as(tmp_file) s2 = pe.load(tmp_file) self.assertEqual(str(s), str(s2)) content = dedent(""" CNY: +----------+----------+------+---+-------+ | 01/09/13 | 02/09/13 | 1000 | 5 | 13.89 | +----------+----------+------+---+-------+ | 02/09/13 | 03/09/13 | 2000 | 6 | 33.33 | +----------+----------+------+---+-------+ | 03/09/13 | 04/09/13 | 3000 | 7 | 58.33 | +----------+----------+------+---+-------+""").strip("\n") self.assertEqual(str(s2), content) os.unlink(tmp_file)
def test_row_filter(self): r = pe.load(self.test_tuple) r.filter(pe.filters.RowFilter([1])) assert r.number_of_rows() == 2 assert r.number_of_columns() == 4 result = [1, 2, 3, 4, 9, 10, 11, 12] actual = pe.utils.to_array(r.enumerate()) assert result == actual # filter out last column and first column r = pe.load(self.test_tuple) r.filter(pe.filters.RowFilter([0, 2])) assert r.number_of_rows() == 1 assert r.number_of_columns() == 4 result = [5, 6, 7, 8] actual = pe.utils.to_array(r.enumerate()) assert result == actual # filter out all r = pe.load(self.test_tuple) r.filter(pe.filters.RowFilter([0, 1, 2])) assert r.number_of_rows() == 0 result = [] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def test_row_index_filter(self): r = pe.load(self.test_tuple) filter_func = lambda x: x in [1] r.add_filter(pe.filters.RowIndexFilter(filter_func)) assert r.number_of_rows() == 2 assert r.number_of_columns() == 4 result = [1, 2, 3, 4, 9, 10, 11, 12] actual = pe.utils.to_array(r.enumerate()) assert result == actual # test removing the filter, it prints the original one r.clear_filters() result = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def test_column_index_filter(self): r = pe.load((self.file_type, self.testfile.getvalue())) test_func = lambda x: x in [0, 2] r.add_filter(pe.filters.ColumnIndexFilter(test_func)) assert r.number_of_rows() == 3 assert r.number_of_columns() == 2 result = [2, 4, 6, 8, 10, 12] actual = pe.utils.to_array(r.enumerate()) assert result == actual # test removing the filter, it prints the original one r.clear_filters() result = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def test_column_filter(self): r = pe.load((self.file_type, self.testfile.getvalue())) r.filter(pe.filters.ColumnFilter([0, 2])) assert r.number_of_rows() == 3 assert r.number_of_columns() == 2 result = [2, 4, 6, 8, 10, 12] actual = pe.utils.to_array(r.enumerate()) assert result == actual # filter out last column and first column r = pe.load((self.file_type, self.testfile.getvalue())) r.filter(pe.filters.ColumnFilter([0, 3])) assert r.number_of_rows() == 3 assert r.number_of_columns() == 2 result = [2, 3, 6, 7, 10, 11] actual = pe.utils.to_array(r.enumerate()) assert result == actual # filter out all r = pe.load((self.file_type, self.testfile.getvalue())) r.filter(pe.filters.ColumnFilter([0, 1, 2, 3])) assert r.number_of_columns() == 0 result = [] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def test_row_index_filter(self): r = pe.load((self.file_type, self.testfile.getvalue())) def filter_func(x): return x in [1] r.add_filter(pe.filters.RowIndexFilter(filter_func)) assert r.number_of_rows() == 2 assert r.number_of_columns() == 4 result = [1, 2, 3, 4, 9, 10, 11, 12] actual = pe.utils.to_array(r.enumerate()) assert result == actual # test removing the filter, it prints the original one r.clear_filters() result = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] actual = pe.utils.to_array(r.enumerate()) assert result == actual
def main(base_dir): # Simple give the file name to **Reader** # "example.xls","example.xlsx","example.ods", "example.xlsm" spreadsheet = pe.load(os.path.join(base_dir,"example.csv")) # row_range() gives [0 .. number of rows] for r in spreadsheet.row_range(): # column_range() gives [0 .. number of ranges] for c in spreadsheet.column_range(): # cell_value(row_index, column_index) # return the value at the specified # position # please note that both row_index # and column_index starts from 0 print(spreadsheet.cell_value(r, c))