1

I have a large dataset in a single file, consisting of one positive integer per line. The file is more than 20GB in size, and before I do anything with the data I need to validate that everything is as I expect it. For this, I need to check that the number on line $n$ is always strictly greater than the one on line $n-1$.

How can I achieve this in an efficient manner?

This is how I am loading the file into memory:

(* Load the data file *)
SetDirectory[NotebookDirectory[]];
Print[DateString[], " - Loading dataset..."]
dataset = ReadList["dataset.txt"];

And I can simply access the element at index $i$ with

dataset[[i]]

Thanks!


PS. I am using Mathematica 11.1 and I have a lot of RAM, so space is not an issue.

Klangen
  • 1,009
  • 5
  • 14

1 Answers1

1

You can use Thread and And.

l1 = {1, 2, 3, 4};
And @@ Thread[Rest[l1] > Most[l1]]
True
l2 = {4, 2, 3, 4};
And @@ Thread[Rest[l2] > Most[l2]]
False

Hope this helps

Edmund
  • 42,267
  • 3
  • 51
  • 143