Home > Enterprise >  Cropping a large file of data
Cropping a large file of data

Time:06-04

I have a massive file of data that is to big to process in any way. The file is structured like below. To be able to process the data i would like to crop out steps of data so i only have every 50 step in the file. It would then end up with data from Direct configuration= 1, Direct configuration= 50 and so on. Does anyone have any idea where to start to achieve this?

Generic Input
           1
     9.911879   -0.001977    0.001562
    -0.002156   10.766003    0.001154
     0.002104    0.001503   12.939863
   Si   Ge   Li   N    O
     8    24    32    32    32
Direct configuration=     1
   0.24672335  0.21343837  0.06644162
   0.25680732  0.21274439  0.56108128
   0.75202052  0.21114493  0.06961516
   .
   .
   .
Direct configuration=     2
   0.24650415  0.21279551  0.06873548
   0.25388539  0.21261272  0.55851287
   0.74968128  0.20877708  0.06763310
   .
   .
   .

and so on

CodePudding user response:

When you read the file you can make diffrent statements and change the destination if the mod of row is 0. like:

count = 0
with open(file,''r) as file:
  for row in file:
    count  =1
    if count % 50 = 0
      --change destination--
  • Related