'Save multiple/distinct .CSV files after for loop execution
I have 65 xml files that I need to convert to .CSV, and save each converted file as a separate .CSV file. I have tried using a for loop but am not having any luck saving the .csv files, however I am able to print the converted (csv) data frames to the console. Below is an example of the code I've tried:
import pandas_read_xml as pdx
import os
path_folder=r'path'
with os.scandir(path_folder) as files_and_folders:
for element in files_and_folders:
if element.is_file():
df=pdx.read_xml(filename,['EPSExtract'])
df=pdx.fully_flatten(df)
df.to_csv(dir_name, index=False, line_terminator='\n')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|