Python Exercise #8 | How to parse values from excel and generate multiple files

Publicado em: 16 Agosto 2020
no canal de: Technolazy
14
0

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


Nesta página do site você pode assistir ao vídeo on-line Python Exercise #8 | How to parse values from excel and generate multiple files duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Technolazy 16 Agosto 2020, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 14 vezes e gostou 0 espectadores. Boa visualização!