I need a help from the community to read the set of data points column wise and save complete 1st column's data set as a array variable in Arduino. Similarly, continue for n number of columns. The csv file must be read from SD card.
What does the 1985 relate to and where did it come from ? It is not in your sample file
It looks like you would be better off using a 2 dimensional array for target
One row per data row and one column per data item
Read from the file and add each character to a temporary char array. When you get a comma add a trailing '\0' to the char[] variable to turn it into a c-string and use atoi() to convert it to an int variable and save it in the current column of the current row of the data array
increment the currentColumn counter
Carry on reading characters, processing them, adding them to the data array until you get a carriage return signalling the end of row
Set currentColumn to zero and increment currentRow
Keep going until you have read the entire file
Looking at the sample file it has nearly 2000 rows in it so depending on which processor you are using then memory for the arrays may be a problem but I am not clear exactly what you want to do, so please give more details of the requirements and your hardware
Would be easier to have a multi-dimensional array or array of struct, but even with separate arrays it will be much faster to process all columns at the same time, reading the file from SD card is the slowest operation.
I was going to create an example of what I suggested in reply #1 but when I looked at the sample file and found that it had nearly 2000 rows, each of 5 integers I stopped because of memory constraints and posted reply #3 to clarify the requirement and the hardware being used
Fairly easy using strtok() to locate the commas and atoi() to convert to integers. If you intend to process each column separately because of memory constraints that will necessitate reading the file multiple times, but presents no problem parsing each line, just ignore the unused column data.
Apologies for replying delay. Purpose is to play the datalog.csv file in Arduino Mega 2560 which contains PWM signals of 4 servo actuators logged at 80 to 110 millisecond interval and 8 motors signals logged at 20 to 30 millisecond.
Read the datalog.csv file from SD card and store it in array variable name as
array Time delay of servo, array time delay of motors, Array motor1pwm..... Array motor8pwm, Array servo1pwm...... Array servo4pwm.
Write the above Array variable (PWM signal) to PWM pins of Arduino Mega 2560 and execute it with the Time delay of servo and motors.
So, this will run the 8 motors (controlled by ESC) and 4 servos connected to battery using datalog.csv file as reference.
Application: This setup is used to test the battery duration and life cycle for recorded data.
Please let me know if you need any further clarification from my end.