0

I have an Excel file which looks like below:

enter image description here

While parsing the file, instead of creating variables manually, I want to use the column names to be used automatically. Is it possible?

For each row, it should loop in something like this:

Name = "John";
Age = "29";
Country = "USA";

I have a bigger file to parse which has more than 100 columns.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
  • Why? How are you planning on using those variables? I don't think the dupe target is appropriate, this looks more like an XY problem. – Cerbrus Sep 26 '22 at 13:34
  • How are you currently parsing the Excel file? Without knowing what you have it's impossible to suggest something... – fbitterlich Sep 26 '22 at 13:34
  • The bigger file I am working on. For now I am using something like this (if that helps). var headers = parser.getColumnHeaders(); gs.info(headers); var headerCount = headers.length; var header1 = header[0]; var header2 = header[1]; var header3 = header[2]; – Soumyadipta Ganguly Sep 26 '22 at 13:38
  • I thought of using like following. But it will be confusing while referring variables from the big file. var markers = []; for (var i = 0; i < coords.length; ++i) { markers[i] = "some stuff"; } – Soumyadipta Ganguly Sep 26 '22 at 13:40

0 Answers0