Really Basic CSV

Now for my next totally basic question re: dealing with really simple .CSV files (4items/10-20rows – Names/Titles etc). I just want to open a file (real path to the file – Drive:/Path1/Path2/Path3/File.csv ) or better yet, choose from a picker??

Populate a table or array with each value, then display it in an organized fashion.

Strangely, the part that I have the most problem with is just loading the file. Can anyone point me to video or tutorial that might help me out on this?

Thanks,
Jerry

Take a look at the example panels here: https://support.rossvideo.com/hc/en-us/community/posts/360065970252-Free-DashBoard-Example-Panels-for-Everyone,

In the Reading and Writing Files or Directories folder, there is an example on Reading a CSV File. It takes the content of the CSV and puts it into a structured parameter.

#DashBoard

Thanks Ben, I do have those and they’ve shown me a lot - however even with the CSV example, there are some basics I apparently still don’t have.

I have no issues with the mechanics of the parsing etc. but I still don’t see how the file path is actually derived. As I mentioned, I’d like to see something like:
Drive:/Path1/Path2/Path3/File.csv

but instead there is this:

ogscript.asyncPost(‘CSV Examples/CSV Reader Data.csv’, null, processCSV);

I get the needed script command and such – and see that the file is read from a subfolder but I don’t see the full path. I’d like to be in control of where the file is. I feel that I’m missing a basic concept here so if you could enlighten me, I’d appreciate it.

-Jerry

#DashBoard

‘CSV Examples/CSV Reader Data.csv’ is the path. In this case, it’s relative to the DashBoard folder, so it does not have the Drive:/ part of this. But you can put the whole path instead.

I just made a quick change to the example panel so that it’s getting the file path from a file parameter. Does that help?

Here is the code:

statecode county eq_site_limit hu_site_limit fl_site_limit fr_site_limit tiv_2011 tiv_2012 eq_site_deductible hu_site_deductible fl_site_deductible fr_site_deductible point_latitude point_longitude line construction policyID cols.0 cols.1 cols.2 cols.3 cols.4 cols.5 cols.6 cols.7 cols.8 cols.9 cols.10 cols.11 cols.12 cols.13 cols.14 cols.15 cols.16 function processCSV(fileContent) { if (fileContent == null) { ogscript.debug("CAN'T LOAD FILE"); return; }

var rows = fileContent.split(‘\n’);
var dataByColumn = ; //It is more efficient if we only call “SET” on the parameters once

for (var r = 0; r < rows.length; r++)
{
var cols = rows[r].trim().split(‘,’);
for (var c = 0; c < cols.length; c++)
{
if (c >= dataByColumn.length)
{
dataByColumn.push(); //Add a new column if it wasn’t already created
}
dataByColumn[c][r] = cols[c].trim(); //Push the cell’s value into the array of column data at row “r”
}
}

//Now that we have collected all of the data for each column into an array, we can call setAllValues for the array parameter
for (var c = 0; c < dataByColumn.length; c++)
{
params.setAllValues(‘cols.’ + c, dataByColumn[c]); //Set all of the values in the column
}
}

ogscript.asyncPost(params.getValue(“filename”,0), null, processCSV);

#DashBoard

Ben
Extremely Helpful!
-Jerry

#DashBoard