0

I would like to write some string in a text file as header of my dataframe.

I have tried to use the myfile().format() method because it work very well with float number and formatting. However, it seems to working with me. This is my code:

MyFile=open('./OUTPUT/output.dat','w')
MyFile.write('{}{}').format('date',';')
MyFile.close()

I have tried different options. I get the following error: 'int' object has no attribute 'format'

while I was expecting to have in my file "date;" Thanks for any kind of help

1 Answer 1

1

You are applying the format in the wrong place.

The format is a string method, and you are applying it to the write function result. Change it to:

MyFile=open('./OUTPUT/output.dat','w')
MyFile.write('{}{}'.format('date',';'))
MyFile.close()

I hope it helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.