무회blog

python , excel, csv, read, write 본문

Python

python , excel, csv, read, write

최무회 2022. 7. 1. 13:16
import encodings
from typing import Sequence

from pandas import concat
from conF_01 import *

def read_AllSheet_excel():
    dfe= pd.read_excel(read_file+'.xlsx', sheet_name=None)
    rtn_df = concat(dfe)
    return rtn_df

def read_excel():
    rtn_df= pd.read_excel(read_file+'.xlsx', sheet_name=0)
    return rtn_df

def write_csv(dfd):
    # dfd = dfd.to_csv(write_file+'.csv')
    dfd = dfd.to_csv(write_file+'.csv', encoding='utf-8')
    return dfd

def write_excel(dfd):
    dfd = dfd.to_excel(write_file + '.xlsx', sheet_name=0)
    return dfd

if __name__ == "__main__":
    print('test07')
    path              = 'C:/app/08.Configuration/01.Config_Data/'
    add_path          = 'Write_Csv_Xlsx/'
    read_file_name    = '220630_Custom_filed02'
    write_file_name   = 'write_220630_Custom_filed02'
    read_file         = path + read_file_name
    write_file        = path + add_path  + write_file_name
    rtn_df = read_excel()

    df = write_csv(rtn_df)
    print(df)
Comments