7 examples of 'import excel file in python' in Python

Every line of 'import excel file in 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
this disclaimer
30def import_openpyxl(self):
31 """Import the requests module """
32 try:
33 import openpyxl
34 from openpyxl import load_workbook
35 except ImportError:
36 print("openpyxl module is not installed"\
37 "Please install openpyxl module to"\
38 "perform any activities related to parsing xl sheets")
39 else:
40 self.openpyxl = openpyxl
41 self.load = load_workbook
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

126@classmethod
127def do_import_excel(cls, workbook, models, logger):
128 raise NotImplementedError("Not implemented for %s" % cls)
399def excel_import(self):
400 self.current_project.excel_import()
11def processExcel(filePath, fileName):
12 if "." in fileName:
13 fileName = fileName.split('.')
14 fileName = fileName[0]
15 data = xlrd.open_workbook(filePath)
16 table = data.sheets()[0]
17 nrows = table.nrows
18 ncols = table.ncols
19
20 cs_fields_index = []#filed index
21 golang_fields_index = []#filed index
22 tableKeysIndex = []
23
24 if table.nrows == 0 or table.ncols == 0:
25 print("empty file:" + fileName)
26
27 for index in range(ncols):
28 CS_row = table.cell(1, index).value
29 if CS_row == "C" or CS_row == "CS":
30 cs_fields_index.append(index)
31
32 if CS_row == "S" or CS_row == "CS":
33 golang_fields_index.append(index)
34
35 if len(cs_fields_index) > 0:
36 cs_files.append(fileName)
37 GenCSTableManagerFile(fileName, cs_fields_index, table)
38 GenCSTableData(fileName, cs_fields_index, table)
39
40 if len(golang_fields_index) > 0:
41 go_files.append(fileName)
42 GenGoTableManagerFile(fileName, golang_fields_index, table)
43 GenGolangTableData(fileName, golang_fields_index, table)
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)
56def open_excel_input_file(self, path):
57 if not path or path == '-':
58 if six.PY2:
59 return six.BytesIO(sys.stdin.read())
60 else:
61 return six.BytesIO(sys.stdin.buffer.read())
62 else:
63 return open(path, 'rb')
68def worksheet_from_excel(excel_sheet):
69 worksheet = Worksheet()
70 for col in range(excel_sheet.ncols):
71 for row in range(excel_sheet.nrows):
72 cell = excel_sheet.cell(row, col)
73 if cell.ctype == XL_CELL_ERROR:
74 formula = '=%s' % (error_text_from_code[cell.value], )
75 elif cell.ctype == XL_CELL_DATE:
76 formula = '=DateTime(%s, %s, %s, %s, %s, %s)' % xldate_as_tuple(
77 cell.value, excel_sheet.book.datemode)
78 else:
79 formula = unicode(excel_sheet.cell(row, col).value)
80 worksheet[col + 1, row + 1].formula = formula
81 return worksheet

Related snippets