In this python exercise we are going to see how to parse values from excel and generate multiple files using pandas data frame. This type of scenario is applicable in real time for generating file operations and report generations.
Code used in the video is copied below..
Your feedback and comments are welcome.
Code starts ####
import pandas as pd
import os
ospath = os.chdir('F:\\technolazy\\python')
dir = os.listdir(ospath)
df = pd.read_excel('Excellist.xlsx')
for index,row in df.iterrows():
dept = row["Dept"]
emp_cnt = row["employee_count"]
exp = row["expense"]
print(dept,emp_cnt,exp)
file_name = dept+'.txt'
with open(file_name,'w')as fout:
with open('sampletext.txt','r') as template:
template_read = template.read()
replace_template = template_read.replace('Dept',dept).replace('employee_count',str(emp_cnt)).replace('expense',str(exp))
fout.write(replace_template)
#### Code ends ###
#python exercises
#python learning
#python file handling
#python exercises
En esta página del sitio puede ver el video en línea Python Exercise #8 | How to parse values from excel and generate multiple files de Duración hora minuto segunda en buena calidad , que subió el usuario Technolazy 16 agosto 2020, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 14 veces y le gustó 0 a los espectadores. Disfruta viendo!