python Read and modify csv Data in
Write data
with open('DataSavePathSet.csv', 'w') as myFile:
myFile.writelines(self.DataSavePath)
Reading data
with open('DataSavePathSet.csv', 'r') as csvfile:
self.DataSavePath =csvfile.readlines()[0]
python Read and modify ini The content in
Write address
curpath = os.path.dirname(os.path.realpath(__file__))
cfgpath = os.path.join(curpath, "cfg.ini")
conf = configparser.ConfigParser()
conf.read(cfgpath, encoding="utf-8")
# Add one select
conf.add_section("DataSaveCfg")
# Go to select add to key and value
conf.set("DataSaveCfg", "path", self.DataSavePath)
conf.write(open(cfgpath, "w+", encoding="utf-8")) # w+ Pattern
Read the address
conf = configparser.ConfigParser()
# read ini file
conf.read("cfg.ini", encoding="utf-8")
Refreshpath = conf.get("DataSaveCfg", "path")
python use DataFrame Read and save excel
read
import pandas as pd
e = 'data.xlsx'
data = pd.read_excel(e)
Write
data.to_excel('data.xlsx',index=None) # Will overwrite the original file