0

I need to transform a numpy array:

array(['#fear.', 'Getting so angry.',
       'Change your mind.', ..., 'birthday boy.',
       'Living in the desert.'],
      dtype='<U234')

Into a .txt file, I am a bit stuck on how to do so with a numpy array, any hint? Thank you

What I want to achieve is a big .txt file where all the strings are together, like that:

'#fear, Getting so angry, Change your mind, birthday boy, Living in the desert'

The sentences does not need to be separated by a comma

1
  • yes it does, thank you @Reti43 Commented Mar 11, 2021 at 13:49

1 Answer 1

1

You can try this:

import numpy as np
arr = np.array(['#fear.', 'Getting so angry.',
       'Change your mind.', ..., 'birthday boy.',
       'Living in the desert.'],
      dtype='<U234')

with open('test.txt' ,"w") as file:
    for e in arr:
        file.write(e)
    
Sign up to request clarification or add additional context in comments.

1 Comment

Already answered by Reti43!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.