1

I have a created an array from text file data that has elements that look like this:

19480101 22.4  2.24
19490101 33.1  3.31

However, each of these rows is just one element in the array. This results in the array being a 1-D column. How can I split it up at the whitespaces to create an array with 3 columns instead of one?

2
  • 3
    Do you know about .split() method? Commented Apr 29, 2016 at 18:44
  • Did my answer solve your problem? If so, please check the tick to the left of my answer (so that does not show up in unanswered Q). If not, please specify, what do you need. Commented Apr 30, 2016 at 6:23

1 Answer 1

2

Use split method on string:

print('19480101 22.4  2.24'.split())    
print('19490101 33.1  3.31'.split())
# outputs
['19480101', '22.4', '2.24']
['19490101', '33.1', '3.31']
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.