Python Forum
[split] Converting excel file to txt file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[split] Converting excel file to txt file
#1
pd.to_string is giving me an error. Is this functionality of pandas still around, or has it been removed? I'm using Python 3. I'm trying to accomplish the same thing the OP was, and stumbled upon this solution that doesn't seem to be working for me. Any help would be appreciated. Thanks!

(Aug-04-2017, 06:23 AM)radioactive9 Wrote: Hello

Since you did not tell what modification you want to make in the file I have no clue what code to write. This will help you to kick start

import pandas as pd
xlsx = pd.read_excel('D:\\Users\\path\\blah_blah.xlsx', sheetname=0, index=0)
'''make necessary changes in the dataframe'''
with open('D:\\Users\\path\\blah_blah.txt','w') as outfile:
    pd.to_string(outfile)
Reply
#2
yes, pandas.DataFrame.to_string() is still available
Also look at pandas.DataFrame.to_csv()

In order to help we need to see your code as well full traceback you get.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Thanks! I wasn't looking for help fixing it directly, I was just trying to find out if .to_string should still work, and/or if it ever worked with Python3. Knowing that .to_string isn't something I should expect to work (I need .DataFrame.to_string) is exactly what I was looking for.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  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
  Export dataframe to xlsx - Error "zipfile.BadZipFile: File is not a zip file" Baggio 10 61,398 Mar-12-2021, 01:02 PM
Last Post: buran
  Python - Merge existing cells of Excel file created with xlsxwriter manonB 0 3,686 Mar-10-2021, 02:17 PM
Last Post: manonB
  Creating more than one excel File at once malvarez1976 0 1,791 Dec-15-2020, 02:04 AM
Last Post: malvarez1976
  XLSX file with multiple sheets to josn file ovidius 2 2,191 Apr-05-2020, 09:22 AM
Last Post: ovidius
  Help batch converting .json chosen file to MySQL BrandonKastning 2 2,286 Mar-14-2020, 09:19 PM
Last Post: BrandonKastning
  Convert Excel to .txt - Need each excel row to be separate .txt file cowboykevin05 2 4,725 Jan-03-2020, 06:29 PM
Last Post: Larz60+
  Python write result of VAR to excel file wissam1974 8 8,512 Jul-13-2019, 01:09 PM
Last Post: wissam1974
  How to add a dataframe to an existing excel file wendysling 2 28,051 May-09-2019, 07:00 PM
Last Post: wendysling

Forum Jump:

User Panel Messages

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