I did some searches but couldn't find a solution to this.
I am loading a csv file and trying to create a separate array for each of the lines. When I try this, I get an error that says I cannot convert string[] to float[].
My original code before creating a csv file was structured like this:
- float[] yearOne = {
- 2009, 4, 0, 1029.85, 1025.21, 1040.46, 1054.72, 1057.57, 1065.48, 1071.49, 1076.18, 1073.18, 1092.02, 1096.56, 1087.68, 1097.91, 1091.06, 1081.4, 1092.91, 1079.6, 1066.94, 1063.41, 1042.63, 1066.11, 1036.18
- };
- float[] yearTwo = {
- 2008, 3, 0, 1161.06, 1114.28, 1099.23, 1056.89, 996.23, 984.94, 909.92, 899.22, 1003.35, 998.01, 907.84, 946.43, 940.55, 985.4, 955.05, 896.78, 908.11, 876.77, 848.92, 940.51, 930.09, 954.09, 968.75
- };
- float[][] yearsAll = {
- yearOne, yearTwo
- };
- 2012,0,1440.67,1444.49,1445.75,1450.99,1461.4,1460.93,1455.88,1441.48,1432.56,,,,,,,,,,,,,,,
- 2011,0,1131.42,1099.23,1123.95,1144.04,1164.97,1155.46,1194.89,1195.54,1207.25,1203.66,1224.58,1200.86,1225.38,1209.88,1215.39,1238.25,1254.19,1229.05,1242,1284.59,1285.08,1253.3,,
- 2010,4,1141.2,1146.24,1137.03,1160.75,1159.97,1158.06,1165.15,1165.32,1169.77,1178.1,1173.81,1176.19,1184.71,1165.9,1178.17,1180.26,1183.08,1185.62,1185.64,1182.45,1183.78,1183.26,,
- 2009,3,1057.07,1029.85,1025.21,1040.46,1054.72,1057.57,1065.48,1071.49,1076.18,1073.18,1092.02,1096.56,1087.68,1097.91,1091.06,1081.4,1092.91,1079.6,1066.94,1063.41,1042.63,1066.11,1036.18,
- 2008,2,1164.74,1161.06,1114.28,1099.23,1056.89,996.23,984.94,909.92,899.22,1003.35,998.01,907.84,946.43,940.55,985.4,955.05,896.78,908.11,876.77,848.92,940.51,930.09,954.09,968.75
- String[] lines = loadStrings("inx-test-one.csv");
- for (int i = 0; i < lines.length; i++) {
- float[][] arrayTest = { float(lines[i]) };
- }
How do I replicate the code in the first block using loadString and a loop?
Thanks, I hope this is clear.
1