You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
468 B
Python
24 lines
468 B
Python
# -*- coding: utf-8 -*-
|
|
# @Time : 2022/11/1 14:26
|
|
# @Author : ZAOXG
|
|
# @File : file_write.py
|
|
|
|
|
|
import pandas as pd
|
|
|
|
__all__ = [
|
|
'write_data'
|
|
]
|
|
|
|
file_type_operation = {
|
|
'csv': 'to_csv',
|
|
'xlsx': 'to_excel',
|
|
'xls': 'to_excel'
|
|
}
|
|
|
|
|
|
def write_data(data, file, index=True, **kwargs) -> pd.DataFrame:
|
|
file_type = file.rsplit('.')[-1]
|
|
temp: pd.DataFrame = getattr(data, file_type_operation[file_type])(file, index=index, **kwargs)
|
|
return temp
|