Skip to content

Instantly share code, notes, and snippets.

@7kry
Created September 22, 2023 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 7kry/2a074a8a9dac92b1369f1fb4fba37f11 to your computer and use it in GitHub Desktop.
Save 7kry/2a074a8a9dac92b1369f1fb4fba37f11 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# coding: utf-8
# In[16]:
from tkinter import filedialog
from tkinter import messagebox
import csv
import xlwings
ENCODING = 'cp932'
# In[18]:
try:
fn = filedialog.askopenfilename(title = 'ミロクから出力した仕訳帳ファイルを開く', filetypes = [('CSV (コンマ区切り)', '.csv')])
if not fn:
exit(1)
with open(fn, encoding = ENCODING) as f:
reader = csv.reader(f)
tbl = list(reader)
rows = len(tbl)
cols = max(map(len, tbl))
b = xlwings.Book()
s = xlwings.sheets.active
s.range(1, 1).value = tbl
s.range((1, 1), (rows, cols))
except Exception as e:
messagebox.showerror('Runtime Error', str(e))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment