Created
September 22, 2023 14:45
-
-
Save 7kry/2a074a8a9dac92b1369f1fb4fba37f11 to your computer and use it in GitHub Desktop.
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
#!/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