10 examples of 'how to read particular column in excel using python' in Python

Every line of 'how to read particular column in excel using python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
19def getCell(self, sheet, row, col):
20 "Get value of one cell"
21 sht = self.xlBook.Worksheets(sheet)
22 return sht.Cells(row, col).Value
59def from_excel(self, cell):
60 raise NotImplementedError()
15def test_excel_col(self):
16 assert_equal(exceltool.excel_column_number("A"), 1)
17 assert_equal(exceltool.excel_column_number("Z"), 26)
18 assert_equal(exceltool.excel_column_number("Z")+1, exceltool.excel_column_number("AA"))
19 assert_equal(exceltool.excel_column_number("AZ")+1, exceltool.excel_column_number("BA"))
20 assert_equal(exceltool.excel_column_number("ZZ")+1, exceltool.excel_column_number("AAA"))
21 assert_equal(exceltool.excel_column_number("CAZ")+1, exceltool.excel_column_number("CBA"))
49def write(self, row_n, col_n, value):
50 '''写入数据,如(2,3,"hello"),第二行第三列写入数据"hello"'''
51 self.ws.cell(row_n, col_n).value = value
52 self.wb.save(self.filename)
280def test_ws_cols(self):
281 ws = Worksheet({'A1': {'v': 11}, 'A2': {'v': 21}, 'B1': {'v': 12}})
282 correct_list = [[11, 21], [12, '']]
283 for i, col in enumerate(ws.cols):
284 self.assertEqual(col, correct_list[i])
131def test_from_excel(self):
132 for excel, internal in (
133 ("TRUE", True),
134 # ("FALSE", False),
135 ("'TRUE", True),
136 # ("'FALSE", False),
137 (1, True),
138 (0, False),
139 ("x", True),
140 ("", None)
141 ):
142 self.assertFromExcel(excel, internal)
92def ncols(self, worksheet):
93 """ Return the number of columns in a worksheet """
94 return self.__sheets__[worksheet]['cols']
44def get_xls_to_list(excelname, sheetname):
45 """
46 读取excel表,返回一个list,只是返回第一列的值
47 return [1,2,3,4,5]
48 """
49 datapath = os.path.join(data_path, excelname)
50 excel = xlrd.open_workbook(datapath)
51 table = excel.sheet_by_name(sheetname)
52 result = [table.row_values(i)[0].strip() for i in range(1,table.nrows)]
53 return result
8def read(self):
9 workbook = self.open_workbook()
10 worksheet = self.get_worksheet(workbook)
11
12 data = self.extract_data(worksheet)
13 data = data[self.options.get('skip', 0):]
14
15 headers = self.options.get('headers', True)
16 if headers is True:
17 headers, data = data[0], data[1:]
18 if headers:
19 return [dict(zip(headers, row)) for row in data]
20 else:
21 return data
34def read_excel_file(f):
35 dialect = csv.Sniffer().sniff(codecs.EncodedFile(f, "utf-8").read(1024))
36 #f.open()
37 return UnicodeCsvReader(codecs.EncodedFile(f, "utf-8"),
38 "utf-8", dialect=dialect)

Related snippets