Creating Variables from Serial Monitor

Hello! I have made a spectrometer for detecting different materials. Currently, I am collecting data on many different solid materials. Rather than copy/pasting the data from the serial monitor, I would like to save the data automatically, correctly formatted, and in my script for later use. For example,

in order to collect the data on different materials, I turn on 5 LEDs sequentially that are pointed at the object, and I read the reflected values from a photodiode. Currently, I simply print that data to the serial monitor. The code is as follows:

Serial.print("========== Learn Mode ==========");
Serial.print('\n');
Serial.println("Object Type: ");
while (Serial.available()==0){
}
objectName = Serial.readString();

for (trialNumber=0;trialNumber<10;trialNumber++) { //trials 0 to 9
for (count=0;count<5;count++) {
digitalWrite(pinArray[count], HIGH); //turn the LEDs on sequentially
delay(25); //wait for stabilization
sensorValue = analogRead(analogPin); //record the value from the sensor
learnedValue[trialNumber][count] = sensorValue;
delay(20);
digitalWrite(pinArray[count], LOW); //turn LED off
delay(100);
}
}
///////Print the Data to Serial Monitor////////////////////
Serial.print('\n');
Serial.print(objectName);
Serial.print(sensorName);
for (trialNumber=0;trialNumber<10;trialNumber++) {
Serial.print('\n');
for (count=0;count<5;count++) {
Serial.print(learnedValue[trialNumber][count]);
Serial.print(" ");
} }
///////////////////////////////////////////////////////////

My goal is to take the mean of the 10 samples, use the "objectName" to create a new variable, and to store the mean of the 10 samples as that variable, which is named whatever is typed into the serial monitor when prompted for "objectName"

The data that I manually inputted is formatted as:
int blueMetalCan[] = {62.4, 39, 25.3, 57.7, 46.5};
int cardboardInsomnia[] = {60.7, 38.8, 11.9, 44.9, 27};
int clearFredWater[] = {145.8, 138.5, 118.5, 152.3, 134.7};
int clearPlasticCup[] = {150.7, 141, 122.4, 156.3, 139.3};

Thank YOU!

If you use another terminal program (such as puTTY) rather than the Arduino Serial Monitor you can configure it to write incoming data to a file.

Alternatively write a PC program to receive and save the data. This Python demo may give you some ideas.

...R