Hi, I currently have a .txt file containing xyz coordinates of 10 particles which looks like:
1.0,2.0,3.0
4.0,5.0,6.0
...
8.0,9.0,10.0
and I want to turn this into an array which is the same shape as the data in the .txt file ie there would be 3 colums representing x,y,z coords and 10 rows representing the 10 particles. Im quite new to python so any help on how to do this would be great
User Profile
Collapse
-
How to write data from a .txt file into an array?
-
thanks that has worked well but I'm struggling to recreate the array from the .txt file. How can I now access the numbers in the file and put them into an array if they are not already part of a list or array? -
How to write an array to a file in python?
Hi, I have generated an array of random numbers and I'm trying to then write this array to a .txt file but the code I have written doesn't seem to do this correctly. I'm fairly new to python so any help on this would be great. Here is what I have so far:
Code:import numpy as N import random def main(): n=10 size=1500 initial=N.zeros([n,3], dtype=N.float64) filename="positions.txt"
No activity results to display
Show More
Leave a comment: