← 返回题库
初级

查询所有会计科目及其分类

未完成
初级参考 完整示例代码供参考,建议自己理解后重新输入
def solve():
    from pyodide.http import open_url
    offices_csv = open_url("https://data.zuihe.com/dbd/core/state_03/offices.csv").read()
    staff_csv = open_url("https://data.zuihe.com/dbd/core/state_03/staff.csv").read()
    savings_products_csv = open_url("https://data.zuihe.com/dbd/core/state_03/savings_products.csv").read()
    clients_csv = open_url("https://data.zuihe.com/dbd/core/state_03/clients.csv").read()
    savings_accounts_csv = open_url("https://data.zuihe.com/dbd/core/state_03/savings_accounts.csv").read()
    savings_account_transactions_csv = open_url("https://data.zuihe.com/dbd/core/state_03/savings_account_transactions.csv").read()
    gl_accounts_csv = open_url("https://data.zuihe.com/dbd/core/state_03/gl_accounts.csv").read()
    journal_entries_csv = open_url("https://data.zuihe.com/dbd/core/state_03/journal_entries.csv").read()
    import sqlite3
    import pandas as pd
    from io import StringIO

    conn = sqlite3.connect(':memory:')
    pd.read_csv(StringIO(gl_accounts_csv)).to_sql('gl_accounts', conn, index=False, if_exists='replace')

    result = pd.read_sql_query("""
        SELECT gl_code, name, type
        FROM gl_accounts
        ORDER BY type, gl_code
    """, conn)
    print(result.to_string(index=False))
    conn.close()

示例

输入
solve()
期望输出
gl_code        name      type
 1001.00 现金及存放中央银行款项     ASSET
 1001.01        库存现金     ASSET
 1001.02    存放中央银行款项     ASSET
 5001.00        实收资本    EQUITY
 5001.01        注册资本    EQUITY
 3001.00        利息支出   EXPENSE
 3001.01    活期存款利息支出   EXPENSE
 3001.02    定期存款利息支出   EXPENSE
 4001.00        利息收入    INCOME
 4001.01      贷款利息收入    INCOME
 2001.00        吸收存款 LIABILITY
 2001.01      个人活期存款 LIABILITY
 2001.02      个人定期存款 LIABILITY
 2001.03      单位活期存款 LIABILITY
Python 代码 🔒 登录后使用
🔒

登录后即可练习

注册免费账号,在浏览器中直接运行 Python 代码