Skip to content

Instantly share code, notes, and snippets.

@rovesoul
Last active March 12, 2020 09:29
Show Gist options
  • Save rovesoul/1bd4a7c4ec8f54adcd459ef418332383 to your computer and use it in GitHub Desktop.
Save rovesoul/1bd4a7c4ec8f54adcd459ef418332383 to your computer and use it in GitHub Desktop.
xls、csv文件的操作
import pandas as pd, xlrd
path = 'some_one.xls'
def openxls(path):
b = xlrd.open_workbook(path)
count = len(b.sheets())
print(count)
for sheet in b.sheets():
try:
f = pd.read_excel(path, header=None, sheet_name=sheet.name)
rows, cols = f.shape
print(rows, cols)
print(f.head())
for i in range(0, cols):
x = f[i]
print(x)
except:
pass
openxls(path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment