Feb-28-2018, 12:57 AM
Hi All,
I have a series of text files with data and I I have written this code below to extract only information in these 1 - 4 columns
Thank you.
Just to add,
The text .data files I am reading have the following format.
Thank you again.
I have a series of text files with data and I I have written this code below to extract only information in these 1 - 4 columns
from math import * import sys import csv import numpy import scipy.io lines = open(sys.argv[1],'r').readlines() lines = lines[9:] for line in lines: v = line.split(' ') print('{} {} {} {}'.format(v[1],v[2],v[3],v[4]))I want to save the output as .mat, and running the below command, the .mat files are not recognised in Matlab
for file in `ls *.data` do basename=`echo $file | sed 's/\.[^.]*$//'` extname=`echo $file | sed 's/[^0-9]*\([0-9]*\)\.\(.*\)/\2\1/'` echo "Processing file: "$basename python $HOME/dump2hammed.py $basename.data > $extname.mat done exit 0Please assist me with the right code to save as .mat
Thank you.
Just to add,
The text .data files I am reading have the following format.
ITEM: TIMESTEP 1000 ITEM: NUMBER OF ATOMS 139 ITEM: BOX BOUNDS ff ff ff -2.5 0.5 -3 1.5 -1 1 ITEM: ATOMS id type x y z ix iy iz vx vy vz fx fy fz omegax omegay omegaz radius 1 1 -0.0749673 0.772667 -0.466103 0 0 0 0 -2.6883 0 0 -0.135604 0 0 0 0 0.01 2 1 -0.292972 0.843474 -0.60076 0 0 0 0 -2.41558 0 0 -0.135604 0 0 0 0 0.01 3 1 -0.209048 0.807345 -0.677375 0 0 0 0 -2.55881 0 0 -0.135604 0 0 0 0 0.01 4 1 -0.238869 0.804225 -0.758702 0 0 0 0 -2.57058 0 0 -0.135604 0 0 0 0 0.01 5 1 -0.176754 0.804198 -0.652818 0 0 0 0 -2.57058 0 0 -0.135604 0 0 0 0 0.01So I am just interested in the type, x, y, z information, and I want the output to be in .mat
Thank you again.