python 写入.xlsx 数据

如题。
This is initally generated by OpenAI and further polished by the auther.
chatGPT的出现大大降低了编程的门槛,估计这些社区的活动量会越来越低。在社区大量的低质量内容中寻找资源的效率远低于与大数据模型进行直接对话。这个账号好久不更新了,预计以后对于工具类代码的更新会越来越少。AI 不会取代人类,取代的是不善于使用AI的人。

pip install openpyxl
import openpyxl

# Load the Excel file
file_path = 'path_to_your_file.xlsx'
workbook = openpyxl.load_workbook(file_path)

# Select a specific sheet (replace 'Sheet1' with your sheet name)
sheet = workbook['Sheet1']

# Initialize a 2D matrix (list of lists) to store the data
matrix = []

# Iterate through rows and store each row as a list in the matrix
for row in sheet.iter_rows(values_only=True):
    matrix.append(list(row))

# Close the workbook
workbook.close()

# Now 'matrix' contains the Excel data as a 2D matrix
for row in matrix:
    print(row)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值