Hello, here is my script to merge data into a single file.
files=dir('*.data');fileout='merged.data';fout=fopen(fileout,'w');for cntfiles=1:length(files)fin=fopen(files(cntfiles).name); linecount = 0; while ~feof(fin) linecount = linecount + 1; linetext = fgetl(fin); if linecount >= 10 % Nine (9) header lines being skipped
fprintf(fout, '%s %d\n', linetext, cntfiles); end end fclose(fin);endfclose(fout);
Original data structure is like this:
ITEM: TIMESTEP1000ITEM: NUMBER OF ATOMS362ITEM: BOX BOUNDS mm mm mm-1.1 1.1-1.00019 1.9-0.75007 0.75007ITEM: ATOMS id type type x y z ix iy iz vx vy vz fx fy fz omegax omegay omegaz radius 1 1 1 0.450082 1.76687 -0.101338 0 0 0 -0 -1 -0 0 0 0 0 0 0 0.0324 2 1 1 -0.0949301 1.76202 -0.0205438 0 0 0 -0 -1 -0 0 0 0 0 0 0 0.0324 3 1 1 0.0403266 1.78975 0.0742209 0 0 0 -0 -1 -0 0 0 0 0 0 0 0.0324
The code works well to merge the individual .data files but the resulting merged.data have an extra column at the end (20 column) with the id of the data input. For instance, below is the point of interface of data from two files;
360 1 1 -0.146193 1.86848 0.0697032 0 0 0 -0 -1 -0 0 0 0 0 0 0 0.0189 1361 1 1 -0.265613 1.86954 0.0197866 0 0 0 -0 -1 -0 0 0 0 0 0 0 0.0189 1362 1 1 0.217502 1.7725 0.0649903 0 0 0 -0 -1 -0 0 0 0 0 0 0 0.0189 11 1 1 0.450082 1.75687 -0.101338 0 0 0 -0 -1 -0 0 0 0 0 0 0 0.0324 22 1 1 -0.0949301 1.75202 -0.0205438 0 0 0 -0 -1 -0 0 0 0 0 0 0 0.0324 23 1 1 0.0403266 1.77975 0.0742209 0 0 0 -0 -1 -0 0 0 0 0 0 0 0.0324 2
Can you kindly help to address this. Thank you.
Best Answer