mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
init python part (#7)
This commit is contained in:
21
python/parser/excel_parser.py
Normal file
21
python/parser/excel_parser.py
Normal file
@ -0,0 +1,21 @@
|
||||
from openpyxl import load_workbook
|
||||
import sys
|
||||
|
||||
|
||||
class HuExcelParser:
|
||||
def __call__(self, fnm):
|
||||
wb = load_workbook(fnm)
|
||||
res = []
|
||||
for sheetname in wb.sheetnames:
|
||||
ws = wb[sheetname]
|
||||
lines = []
|
||||
for r in ws.rows:
|
||||
lines.append(
|
||||
"\t".join([str(c.value) if c.value is not None else "" for c in r]))
|
||||
res.append(f"《{sheetname}》\n" + "\n".join(lines))
|
||||
return res
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
psr = HuExcelParser()
|
||||
psr(sys.argv[1])
|
||||
Reference in New Issue
Block a user