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

Viktor.w
  • 1,787
  • 2
  • 20
  • 46

1 Answers1

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)
    
kabooya
  • 447
  • 3
  • 14