Importing CSV file to Arduino

Hey,
I am new in Arduino and want to import a CSV file to use its data as an array in my code. It would be great if you help me with the process.

Thamks

Do you want to read the file at run time or into the IDE ?

If the latter, copy the csv file contents into the IDE and a bit of editing, job done

It has more than thousands of numbers in it that I want to use. That is why it is too hard to copy them to the IDE.
Is there any easier way to read the data from the CSV file in IDE?

Thanks

You could read the CSV from an SD card directly into the array levels but how many entries will you have in the array, what data type are they and which Arduino board are you using ?

Thanks for the response.
They are hourly sun angles.

You are not giving enough details

Please attach the CSV file that you want to import

Sorry for my late response.
Here is the CSV file.

HourlyAngle.txt (3.87 KB)

What I actually want to do is to read the hourly angles from the CSV file and rotate my object through servo/stepper motor. Does it make sense? Please let me know if any ambiguous point is in my work.

Thanks

I've removed the first column.

float solarAngles[]
{
345.8691023,
347.3633945,
348.866858,
350.3785127,
351.8973317,
353.422246,
354.952151,
356.4859117,
358.02237,
359.5603512,
1.098671184,
2.636143866,
4.171588313,
5.703836038,
7.231738038,
8.754171556,
10.27004649,
11.77831132,
13.27795857,
14.76802963,
16.24761901,
17.71587788,
19.17201705,
20.61530917,
22.04509031,
23.460761,
24.8617865,
26.24769664,
27.61808513,
28.97260834,
30.31098374,
31.63298798,
32.93845464,
34.22727178,
35.49937928,
36.75476606,
37.9934672,
39.21556104,
40.42116619,
41.6104387,
42.78356914,
43.94077989,
45.08232243,
46.20847478,
47.31953913,
48.41583949,
49.49771963,
50.56554105,
51.61968118,
52.66053172,
53.68849715,
54.70399333,
55.70744638,
56.69929156,
57.67997243,
58.64994005,
59.60965237,
60.55957376,
61.50017464,
62.43193124,
63.3553255,
64.27084507,
65.17898346,
66.08024025,
66.97512151,
67.86414018,
68.74781675,
69.62667994,
70.5012675,
71.37212722,
72.239818,
73.10491106,
73.96799132,
74.82965894,
75.69053103,
76.55124349,
77.41245313,
78.27483991,
79.13910954,
80.00599619,
80.87626564,
81.75071863,
82.63019465,
83.51557607,
84.40779273,
85.30782708,
86.21671978,
87.13557599,
88.06557238,
89.00796488,
89.96409735,
90.93541127,
91.92345653,
92.92990354,
93.95655678,
95.00536992,
96.07846288,
97.17814083,
98.30691559,
99.46752953,
100.6629824,
101.8965611,
103.1718732,
104.492884,
105.863957,
107.2898994,
108.7760101,
110.3281325,
111.9527089,
113.656837,
115.4483244,
117.3357388,
119.3284473,
121.4366374,
123.6713076,
126.0442124,
128.5677403,
131.2546976,
134.1179669,
137.1699999,
140.4221116,
143.883543,
147.5602877,
151.4537156,
155.5590916,
159.8641659,
164.3480973,
168.9810166,
173.724517,
178.53323,
183.3574244,
188.1463045,
192.8514863,
197.4300752,
201.846888,
206.075596,
210.0988237,
213.9074232,
217.4992316,
220.8776071,
224.0499717,
227.0265071,
229.8190728,
232.4403621,
234.9032778,
237.2204956,
239.4041749,
241.465784,
243.4160066,
245.2647076,
247.0209368,
248.692958,
250.2882941,
251.8137788,
253.2756128,
254.6794195,
256.0302988,
257.3328782,
258.5913598,
259.8095639,
260.9909681,
262.1387427,
263.2557832,
264.3447385,
265.4080366,
266.4479075,
267.4664037,
268.4654186,
269.4467023,
270.4118763,
271.3624466,
272.2998153,
273.2252905,
274.1400961,
275.0453799,
275.9422208,
276.8316361,
277.7145869,
278.5919837,
279.4646918,
280.3335348,
281.1992994,
282.0627385,
282.9245749,
283.7855037,
284.6461957,
285.5072992,
286.3694424,
287.2332357,
288.0992729,
288.9681336,
289.8403839,
290.7165782,
291.5972604,
292.4829644,
293.3742158,
294.271532,
295.1754232,
296.0863928,
297.0049382,
297.9315504,
298.8667149,
299.8109115,
300.7646141,
301.7282908,
302.7024036,
303.6874079,
304.6837518,
305.6918759,
306.7122118,
307.745182,
308.791198,
309.8506595,
310.9239528,
312.0114494,
313.113504,
314.2304531,
315.3626123,
316.5102748,
317.6737085,
318.8531538,
320.0488211,
321.2608877,
322.4894954,
323.7347475,
324.9967058,
326.2753875,
327.5707629,
328.8827517,
330.2112212,
331.5559829,
332.9167904,
334.2933377,
335.6852565,
337.0921159,
338.5134202,
339.9486094,
341.3970588,
342.8580792,
344.3309189,
};

I've used Notepad++ under Windows.

Steps:
1)
Do a regular expression search and replace to get rid of the first column
Find what: ^[0-9]*,
Replace with: leave this empty
Select regular expression for the search mode
Click replace all
2)
Do an extended search and replace to replace the line ending by a comma followed by the line-ending
Find what: \r\n
Replace with: ,\r\n
Select extended for the search mode
Click replace all
3)
Cleanup

added float solarAngles{ at the beginning
added }; at the end
removed other stuff

Hope this helps in the future.