Python Forum
[split] Converting excel file to txt file - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: [split] Converting excel file to txt file (/thread-21830.html)



[split] Converting excel file to txt file - unexceptionalhobby - Oct-16-2019

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)



RE: Converting excel file to txt file - buran - Oct-16-2019

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.


RE: [split] Converting excel file to txt file - unexceptionalhobby - Oct-16-2019

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.