Python Forum

Full Version: [split] Converting excel file to txt file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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)
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.
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.