Python Forum

Full Version: Convert Excel to .txt - Need each excel row to be separate .txt file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Disclaimer: total python newb here

I have an Excel file with thousands of rows & 10 columns (with header as row 1).

I need each row (excluding header) to be saved as an individual (tab delimited) .txt file.

Column "A" from each row of the excel file needs to be the file name for each .txt file. The remaining columns need to be the (tab delimited) text within each file.

Example (below) of what I have and what I need... I did this manually for 1 row... but I have thousands of rows. Anybody know where I can find python script to execute this? Please and thank you!

İmage

İmage


Sorry, my first post here... I didn't realize I couldn't add images or edit my post. But I believe my description was clear.
If I would face this task I would use pandas.

Something like that:
- read Excel file with pandas.read_excel
- iterate rows using pandas.DataFrame.iterrows
- write row to file using pandas.Series.to_csv setting sep as '\t'.
agree with perfringo Pandas is the way to go. A bit of a learning curve, but well worth it.
Lots of tutorials on YouTube