Python 处理excel并转为table
使用xlrd
来
读取,xlrd的下载及安装可以参看:
Python
"xlrd" package for extracting data from Excel files
---------------------------------------------------------------------------------
#coding=utf-8
import xlrd
import os, types, datetime
#excel存放目录
dir = u'D:\\temp\\excel'
#生成html存放目录,需要事先建立
htmlroot = u'D:\\temp\\html'
#excel从1899/12/31计算时间
__s_date = datetime.date(1899, 12, 31).toordinal() - 1
#读取时间格式的单元
def getdate(date):
if isinstance(date, float):
date = int(date)
d = datetime.date.fromordinal(__s_date + date)
return d.strftime("%Y-%m-%d")
#遍历文件夹
for root, dirs, files in os.walk(dir):
for file in files:
#生成excel文件路径
path = os.path.join(root, file)
print u'converting... ' + path
book = xlrd.open_workbook(path) #打开excel文件
#遍历excel文件中的sheet
for shn in range(book.nsheets):
sh = book.sheet_by_index(shn)
#判断该表是否为空
if sh.nrows == 0:
continue
#搜索“路径”列
&nbs
相关文档:
1. 手动制作python的exe可执行程序
转载---------------
Python没有内建一个编 ......
前一篇文章写的在APACHE安装MOD_PYTHON的经过,其实挺简单,就是版本不兼容的问题.这次我大概说下部署DJANGO的过程.
先修改APACHE配置文件,使其加载mod_python模块
LoadModule python_module libexec/mod_python.so
运行命令查看
bin/httpd -M可以看到
python_module (shared)
Syntax OK
说明apache已经成功加 ......
ubuntu10.05出来了这两天一直在折腾,显示wubi无反应,然后从硬盘安装期间又遇到grub错误等问题。安装成功后搞个中文输入法就老半天,最后使用Pinyin这个还算好用,有点想搜狗就是没什么词库。最恶心的还是vim的问题,用apt-get install vim装的vim不支持系统剪切板,只好从源代码编译,可是我尝试了很多次总是没有python支 ......
>>> import time
>>> import datetime
>>>
now = time.localtime()
>>> now
(2006, 4, 30, 18, 7, 35,
6, 120, 0)
>>> type(now)
<type 'time.struct_time'>
>>>
str_now = time.strftime("%m/%d/%Y %X", now )
>>>
str_n ......
很长的一段代码,但很清楚。哈哈。
import os
from time import strftime
stamp=strftime("%Y-%m-%d %H:%M:%S")
logfile = 'F:\\test\\m-php-framework\\tmp\logs\\error_report.log'
path = 'F:\\test\\'
files = os.listdir(path)
bytes = 0
numfiles = 0
for f in files:
if f.startswith('t'): ......