ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

python ¿Ä¸ê¿Ä¨é·JÁ` (¥þ³¡)"¸ê®Æ

¦^´_ 10# c_c_lai


   

TOP

¦^´_ 11# lpk187
§Ú¦A¸Õ¸Õ¬Ý !
(¸ÕµÛ¥ý±N¸ê®Æ®w²¾°£¡B¦b°õ¦æ)>

TOP

¥»©«³Ì«á¥Ñ c_c_lai ©ó 2016-9-25 10:21 ½s¿è

¦^´_ 11# lpk187
­«·s´ú¸Õµ²ªG¡G

ÁÂÁ§A¡I
¦pªG­n±q¸ê®Æ®wŪ¨ú¥X¸ê®Æ¤S¸Ó¦p¦ó¼¶¼g¡A
Ä´¦p¦P¨B'¼g¤J pandas ¸Ì¡H ©Î¬O¨ä¥L¤è¦¡¡H

TOP

¦^´_ 13# c_c_lai


    ¦bpython ¤¤¡A§Ú¤]ÁÙ¬O¦b¾Ç²ß¡A©Ò¥Hª¾¹Dªº¬Æ¤Ö
­n±q¸ê®Æ®w¤¤®³¥X¨Ó¡A¥HPywin32 ADODBªº¥Îªk©MVBA«ÜÃþ¦ü

§A¥i¥H°Ñ¦Òhttp://wiki.alarmchang.com/index.php?title=Python ¸Ì­±¦³«Ü¦h¨Ò¤l°Ñ¦Ò
¬Æ¦Ü±±¨îExcel³£¥i¥H¡A´N­n¬Ý±q¸ê®Æ®w¤¤´£¨ú¥X¨Ó«á­n°µ¤°»ò(¦]¬°§Ú¨Sª±ªÑ²¼¡A¤]¤£ª¾¹D³o¨Ç¼Æ¾Ú¸Ó¥Î¤°»ò¡H³o°ÝÃD¥i¯à­n½Ð±Ð¦U¦ì¤j¤j¤F)

TOP

¥»©«³Ì«á¥Ñ koshi0413 ©ó 2016-9-25 14:30 ½s¿è

¦^´_ 13# c_c_lai

µ¹±z°Ñ¦Ò  SQLite3 ¾É¤J Excel
acc§@ªkÀ³¸Ó¤]®t¤£¦h

ª`·N!!! ³o¬O¤@¦¸¥þ¾É¤J¡A©Ò¥H¸ê®Æ¶q¤Ó¤j¡A·|«ÜºC
À³¸Ó¥i¥H¾É¤J§½³¡¡A¥u¬O¤p§Ì©|¥¼¥Î¨ì¡AÁÙ¨S²`¤J
  1. Sub SQLite3_to_Excel()
  2. ¦L¹³¤¤¥i¥H¦b "SELECT  *  FROM  " & TableName & " "  ¥[¤J¥u´£¨ú¤Q¦æ

  3. Dim cn, rs, f, SQLName, TableName, ix%, SheetsName

  4.     SQLName = "C:\Users\Koshi\Documents\Python Scripts\SQLite3\2330.sqlite"
  5.     TableName = "sqlªí®æ¦WºÙ"
  6.     SheetsName = "Excel¤u§@ªí¦WºÙ"
  7.     ix = 10 '¶}©l©ó²Ä¤Q¦æ
  8.    
  9.     Sheets(SheetsName).Select
  10.     Set cn = CreateObject("adodb.connection")
  11.         cn.Open ("Driver={SQLite3 ODBC Driver};database=" & SQLName)     '¶}±Òsqlite«ü©w¸ê®Æ®w¡A¸ô®|»PÀɮצWºÙ­n¹ï
  12.         Set rs = cn.Execute("SELECT  *  FROM  " & TableName & " ")       '¼g¥XSQL¬d¸ß»yªk
  13.             Sheets(SheetsName).Cells.Delete  '²M°£¤u§@ªí¸ê®Æ
  14.             For f = 0 To rs.Fields.Count - 1
  15.                 Sheets(SheetsName).Cells(ix, f + 1).Value = rs.Fields(f).Name   '¾É¤JÄæ¦ì¦WºÙ
  16.             Next
  17.             Sheets(SheetsName).Cells(ix + 1, 1).CopyFromRecordset (rs)        '¾É¤JÄæ¦ì¸ê®Æ
  18.         cn.Close
  19.     Set rs = Nothing
  20.     Set cn = Nothing
  21. End Sub
½Æ»s¥N½X

TOP

¦^´_  c_c_lai

µ¹±z°Ñ¦Ò  SQLite3 ¾É¤J Excel
acc§@ªkÀ³¸Ó¤]®t¤£¦h

ª`·N!!! ³o¬O¤@¦¸¥þ¾É¤J¡A©Ò¥H¸ê ...
koshi0413 µoªí©ó 2016-9-25 14:25


§ä¨ì¤F ¦¹¥N½X¬° joey0415 ¤j¤j¼gªº
http://forum.twbts.com/viewthread.php?tid=9984

TOP

¥»©«³Ì«á¥Ñ lpk187 ©ó 2016-9-25 17:22 ½s¿è

¦^´_ 13# c_c_lai


¬ã¨s¤F¤@¤U   pandas ¨ú¥X ¦A¾É¤J¨ìCSV ©ÎExcel
  1. import pypyodbc
  2. import pandas as pd

  3. MDB = 'D:\\Python\\¿Ä¸ê¿Ä¨é·JÁ`\\twsedata.mdb'
  4. DRV = '{Microsoft Access Driver (*.mdb, *.accdb)}'
  5. con = pypyodbc.connect('DRIVER={};DBQ={}'.format(DRV, MDB))
  6. data = pd.read_sql('select * from 1220', con) # ¨ú¥X
  7. data.to_excel('1220.xlsx', sheet_name='1220')  #¾É¤J¨ìExcel
  8. data.to_csv('1220.csv') #¾É¤J¨ì CSV
  9. data
½Æ»s¥N½X

TOP

¦^´_ 17# lpk187
´ú¸Õµ²ªG¦p¤U¡G

±q¦h­Ó¨¤«×¨Ó´ú¸Õ¡A¹ê¦b¤Ó´Î¤F¡C
ÁÂÁÂÅo¡I

TOP

¦^´_ 17# lpk187
½Ð±Ð¦pªG´«¦¨ 15# ¼Ó koshi0413 ©Ò»¡ªº SQLite3
­n¦p¦ó³sµ²¡H

TOP

¦^´_ 19# c_c_lai


   ¤£¦n·N«ä¡I¨S¥Î¹LSQLite3¡A¤£ª¾«ç»ò¦^µª§A
§A¥i¥H°Ñ¦Òhttp://www.runoob.com/sqlite/sqlite-python.html
¥H¤Îhttps://docs.python.org/3.5/library/sqlite3.html

TOP

        ÀR«ä¦Û¦b : ¡i¬°µ½Ävª§¡j¤H¥Í­n¬°µ½Ävª§¡A¤À¬í¥²ª§¡C
ªð¦^¦Cªí ¤W¤@¥DÃD