User Profile

Collapse

Profile Sidebar

Collapse
k voller
k voller
Last Activity: Mar 29 '11, 04:20 PM
Joined: Jan 30 '11
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • k voller
    started a topic How to write data from a .txt file into an array?

    How to write data from a .txt file into an array?

    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
    See more | Go to post

  • k voller
    replied to How to write an array to a file in python?
    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?
    See more | Go to post

    Leave a comment:


  • k voller
    started a topic How to write an array to a file in python?

    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"
    ...
    See more | Go to post
    Last edited by bvdet; Jan 30 '11, 06:26 PM. Reason: Fix code tags
No activity results to display
Show More
Working...