Data from txt file

I have to read a file with 4000 lines or more, when i run this code the sketch reads something near to 500 lines only. Is there some kind of limitation? i’d try with double variables too but didan’t work.

//global variables
String[] str;
float[] pressao = new float [100000];
float[] alt = new   float [100000];
float[] pitch=new   float [100000];
float[] roll=new   float [100000];

void setup(){
  str = loadStrings("data/DATA.TXT");
  
  String[] arry = new String[str.length];

  for (int i=0; i < arry.length; i++) {
    String[] thisLine = split(str[i] , " " );
    
    pressao[i] =  float (trim(thisLine[0]));
    alt[i] =    float (trim(thisLine[1]));
    pitch[i] = float(trim(thisLine[2]));
    roll[i] = float(trim(thisLine[3]));
    
  print("pressão: "+pressao[i]);
  print(" | altitude: "+alt[i]);
  print(" | pitch: "+pitch[i]);
  println(" | roll: "+ roll[i]);
  }
}

the file its like that:
1016.25 3082.09 -18.17 14.89
1016.26 3082.14 -18.04 15.06
1016.26 3082.14 -18.00 15.00
1016.26 3082.14 -18.29 14.76
1016.26 3082.14 -18.23 15.32
1016.26 3082.14 -18.25 15.18
1016.26 3082.14 -18.03 15.15
1016.26 3082.14 -18.06 15.13
1016.26 3082.14 -18.15 15.09
1016.26 3082.14 -18.08 14.86
1016.26 3082.14 -18.15 15.20
1016.26 3082.14 -18.12 14.94

2 Likes

Much probably the problem is that the PDE’s console is limited. :poop:
That is, you end up seeing the last 500 hundred values logged by your print() commands. :see_no_evil:
But rest assured, your arrays grabbed everything. :relieved:

2 Likes

Nice to know! thanks :grin:

Instead of println you can write in an array and save it as a logfile with saveStrings()

2 Likes