使用Python将数据从MS Access复制到MS Excel [英] Copy data from MS Access to MS Excel using Python

查看:87
本文介绍了使用Python将数据从MS Access复制到MS Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在周末的大部分时间里尝试找出使用Python将数据从MS Access表传输到Excel工作表的最佳方法.我发现了一些可能有用的模块(execsql,python-excel),但是由于我的知识有限,我必须使用这些模块来创建某些数据(我是GIS专业人士,所以我正在使用以下方法创建空间数据将ArcGIS arcpy模块插入访问表)

I've been spending the better part of the weekend trying to figure out the best way to transfer data from an MS Access table into an Excel sheet using Python. I've found a few modules that may help (execsql, python-excel), but with my limited knowledge and the modules I have to use to create certain data (I'm a GIS professional, so I'm creating spatial data using the ArcGIS arcpy module into an access table)

我不确定最好的方法是什么.我需要做的就是从访问Excel复制4列数据,然后格式化Excel.我已经解决了格式化部分.

I'm not sure what the best approach should be. All I need to do is copy 4 columns of data from access to excel and then format the excel. I have the formatting part solved.

我应该:

使用游标遍历行,并以某种方式将行加载到excel中? 将列从访问权限复制到Excel? 将整个访问表导出到excel中的工作表中?

Iterate through the rows using a cursor and somehow load the rows into excel? Copy the columns from access to excel? Export the whole access table into a sheet in excel?

谢谢您的建议.

推荐答案

我目前使用XLRD模块从Excel电子表格中插入数据,并使用插入光标创建要素类,效果很好.

I currently use the XLRD module to suck in data from an Excel spreadsheet and an insert cursor to create a feature class, which works very well.

您应该能够使用搜索光标迭代要素类记录,然后使用XLWT Python模块( http://www.python-excel.org/)将记录写入Excel.

You should be able to use a search cursor to iterate through the feature class records and then use the XLWT Python module (http://www.python-excel.org/) to write the records to Excel.

这篇关于使用Python将数据从MS Access复制到MS Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆