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
#1
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.
Reply
#2
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.
Reply
#3
agree with perfringo Pandas is the way to go. A bit of a learning curve, but well worth it.
Lots of tutorials on YouTube
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Excel iterations and restrictions marialage98 0 115 Mar-23-2024, 11:38 AM
Last Post: marialage98
  Pandas keep existing format of Excel AlphaInc 2 881 Jan-11-2024, 03:44 AM
Last Post: plonkarchivist
  Python outputs to Excel NewBiee 3 812 Nov-26-2023, 07:25 AM
Last Post: DPaul
  How to count total number of sheets in an excel workbook using polars sayyedkamran 0 630 Oct-27-2023, 09:54 PM
Last Post: sayyedkamran
  Write from dictionary to excel divon 3 3,469 Jun-11-2023, 10:37 AM
Last Post: Larz60+
  Data Sorting and filtering(From an Excel File) PY_ALM 0 1,012 Jan-09-2023, 08:14 PM
Last Post: PY_ALM
  Split excel file and write output at specific row and set sheet position DSCA 0 1,958 May-12-2022, 07:29 PM
Last Post: DSCA
  pivot table (excel vs python) Bric 1 1,641 Feb-02-2022, 11:04 PM
Last Post: Bric
  Help with poorly formatted excel data armitron121 1 1,694 Jan-13-2022, 07:31 AM
Last Post: paul18fr
  Exporting data frame to excel dyerlee91 0 1,604 Oct-05-2021, 11:34 AM
Last Post: dyerlee91

Forum Jump:

User Panel Messages

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