copy.py
import shutil
shutil.copy('Copy source path', 'Copy destination path')
move.py
import shutil
shutil.move('Path before moving', 'Path after moving')
encode.py
import codecs
def main():
# UTF-8 File path
utf8_csv_path = 'utf8 file path'
# Shift-jis file path
shiftjis_csv_path= 'shift-jis file path'
#Convert character code to shiftjis and save
fin = codecs.open(utf8_csv_path, "r", "utf-8")
fout_jis = codecs.open(shiftjis_csv_path, "w", "shift_jis")
for row in fin:
fout_jis.write(row)
fin.close()
fout_jis.close()
if __name__ == "__main__":
main()
remove.py
import os
os.remove('File path you want to delete')
renameFile.py
import os
os.rename('File path before change', 'File path after change')
renameColumns.py
import pandas as pd
df = pd.read_csv('202101.csv')
print("Before Column\t"+str(df.columns)) #Column name confirmation
df = df.rename(columns = {'A':'aaa',
'B':'bbb',
'C':'ccc',
'D':'ddd',
'E':'eee',
'F':'fff',
'G':'ggg',
'H':'hhh',
'I':'iii',
})
print("After Column\t"+str(df.columns)) #Confirmation of column name after change
df.to_csv('202101_changeColumnName.csv', index = False) #Write changes to csv
today = datetime.date.today()
print(today.strftime('%Y%m'))
Recommended Posts