Python Code in Jupyter summing each item, each month of 지출-액수.csv in SQLite

import sqlite3
import pandas as pd

# Define the path to your SQLite database
db_path = "/home/jbyungrokim/CSV/CSV.db"

# Connect to the SQLite database
conn = sqlite3.connect(db_path)

# Adjust the query to calculate the sum for each item by year and month
query = """
SELECT 
    strftime('%Y-%m', '20' || substr(Date_Transaction, 7, 2) || '-' || substr(Date_Transaction, 1, 2) || '-' || substr(Date_Transaction, 4, 2)) AS YearMonth,
    Item, 
    SUM(Pay_Amount) AS Total_Spent
FROM 
    '지출-액수_2024_08_20'
GROUP BY 
    YearMonth, Item
ORDER BY 
    YearMonth, Total_Spent DESC;
"""

# Execute the query and store the result in a pandas DataFrame
monthly_sum = pd.read_sql_query(query, conn)

# Reshape the data into a wide format for better readability in a spreadsheet
monthly_sum_wide = monthly_sum.pivot(index='Item', columns='YearMonth', values='Total_Spent').fillna(0)

# Export the data to a CSV file
output_path = "/home/jbyungrokim/CSV/monthly_sum_by_item_Jupyter.csv"
monthly_sum_wide.to_csv(output_path, index=True)

# Print the result
print("Sum of Pay_Amount by Item for each Year/Month:")
print(monthly_sum_wide)

# Close the connection to the SQLite database
conn.close()

지출-액수.csv month by month ITEM sum by R

library(RSQLite)
library(DBI)
library(tidyr)  # For reshaping the data
library(readr)  # For exporting data to CSV

# Define the path to your SQLite database
db_path <- "/home/jbyungrokim/CSV/CSV.db"

# Connect to the SQLite database
conn <- dbConnect(RSQLite::SQLite(), dbname = db_path)

# Adjust the query to calculate the sum for each item by year and month
query <- "
SELECT 
    strftime('%Y-%m', '20' || substr(Date_Transaction, 7, 2) || '-' || substr(Date_Transaction, 1, 2) || '-' || substr(Date_Transaction, 4, 2)) AS YearMonth,
    Item, 
    SUM(Pay_Amount) AS Total_Spent
FROM 
    '지출-액수_2024_08_20'
GROUP BY 
    YearMonth, Item
ORDER BY 
    YearMonth, Total_Spent DESC;
"

# Execute the query and store the result in a data frame
monthly_sum <- dbGetQuery(conn, query)

# Print the result
print("Sum of Pay_Amount by Item for each Year/Month:")
print(monthly_sum)

# Reshape the data into a wide format for better readability in a spreadsheet
monthly_sum_wide <- spread(monthly_sum, YearMonth, Total_Spent, fill = 0)

# Export the data to a CSV file
output_path <- "/home/jbyungrokim/CSV/monthly_sum_by_item.csv"
write_csv(monthly_sum_wide, output_path)

# Print the location of the saved file
print(paste("Data has been saved to:", output_path))

# Close the connection to the SQLite database
dbDisconnect(conn)

404-935-2200

한의원 (EST). parksacupuncture.com 현재 웹 사이트 한번 보고 다시 한번 통화 하기 원함. 현재 웹 사이트 발전 시키는 것을 원하는 듯. 원장 sounds gentle and nice (8/21/2024).

현재 웹 사이트 그럴 듯하고 괜찮으니, 한달에 얼마 지불하고 있는가 물어 보고, 월 $41에 approach 해 볼 것 (8/21/2024).

현재 웹 사이트 유지에 돈은 안 내고 있고, 내가 어떤 도움을 줄 수 있냐고 해서, 웹 사이트 뿐만 아니라 구글 서치 엔진에 등록해서 온라인으로 문의 들어 오게 해 줄 수 있다고 하니, 나중에 연락하겠단다 (8/27/2024).