Last active
March 12, 2020 09:29
-
-
Save rovesoul/1bd4a7c4ec8f54adcd459ef418332383 to your computer and use it in GitHub Desktop.
xls、csv文件的操作
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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