Python Forum
Convert Excel to .txt - Need each excel row to be separate .txt file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert Excel to .txt - Need each excel row to be separate .txt file
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!



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'.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
agree with perfringo Pandas is the way to go. A bit of a learning curve, but well worth it.
Lots of tutorials on YouTube

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with poorly formatted excel data armitron121 1 144 Jan-13-2022, 07:31 AM
Last Post: paul18fr
  Exporting data frame to excel dyerlee91 0 466 Oct-05-2021, 11:34 AM
Last Post: dyerlee91
  [Pandas] Write data to Excel with dot decimals manonB 1 1,096 May-05-2021, 05:28 PM
Last Post: ibreeden
  Python - Merge existing cells of Excel file created with xlsxwriter manonB 0 1,278 Mar-10-2021, 02:17 PM
Last Post: manonB
  Python vs VBA for Excel jfunkitup 3 1,675 Dec-31-2020, 07:56 AM
Last Post: caleb_cruze
  Creating more than one excel File at once malvarez1976 0 772 Dec-15-2020, 02:04 AM
Last Post: malvarez1976
  How to form a dataframe reading separate dictionaries from .txt file? Doug 1 2,636 Nov-09-2020, 09:24 AM
Last Post: PsyPy
  Counting of rows in Excel Spreadsheet dakrantau 2 943 Sep-30-2020, 02:27 AM
Last Post: dakrantau
  Python PDF merging from an excel pandas for loop siraero 0 1,174 Aug-16-2020, 09:34 AM
Last Post: siraero
  How do I translate this into python code? (excel vlookup) eeps24 6 1,411 May-29-2020, 05:54 PM
Last Post: eeps24

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020