Hi Everyone!
I’m just getting into programming and learning the very basics and mostly hacking together things from here and there building tools to suit my needs.
I’m working on trying to make a very basic .csv reader in C# that in psuedo code does the following:
“If read is true, get the file at specified path and read data as string value.”
Here’s the basic graph/node layout:
Here’s an example of what I would like the data to end up as in a panel:
And here’s the C# code inside the script that I’ve been editing:
if(read)
{
var fileinfo = File.ReadAllLines(path);
if(fileinfo.Length == 0)
return;
var index = -1;
if(index == -1)
return;
var list = new List<string>(fileinfo.Length - 1);
for(var i = 1;i < fileinfo.Length;i++)
{
var dataRow = fileinfo[i].Split(',');
if(dataRow.Length <= index){
list.Add(null);
}else{
list.Add(dataRow[index].Trim());
}
}
data = list;
}
It is contained in lines 60-82 and at line 14 I added System.IO
So my question is, am I doing something that is negating my looped values? or am I not looping correctly and thus returning null? Something else?
Thank you for your help! I only know the very basics and enough to be dangerous at this point =/ but I’m eager to learn more!
CSV_Reader_01a.gh (4.4 KB)
csv_c_sharp_read_test_01.csv (7.4 KB)