-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Displaying the records that have been loaded using TextLoader #2466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Would this example satisfies you? if you want to get values in one column we have: |
Also I'd point out that if you wanted just to get some text to see what was going on, you could also have exploited
That is done inside the while loop. Getting that delegate after you create the cursor and using it multiple times, but before you enter the loop, is optimal since creation of the "getter" is a fairly costly operation, but calling the getter itself is cheap. So the pattern is: create cursor, get getters, and iterate over the getter, and in that iteration call the getter to get values. (Note that the values into which you put values should likewise be allocated outside the loop to enable buffer sharing.) For more info on this and its motivations, please see here. Not also that cursors are disposable. In this specific particular case of yours it is I think irrelevant, but if it were something that has to allocate some native memory that has to be cleaned up (e.g., TensorFlow transformer) failure to dispose might lead to memory leaks on the unmanaged heap. |
Thank you. I have taken your suggestions
And amended my block of code
|
Hi @Ivanidzo4ka , Thansk for replying. Works like a charm.
I observed that when I had mapped the property Weight to a Microsoft.ML.Data.DataKind.R4 the code threw an exception. Worked fine when I changed to Microsoft.ML.Data.DataKind.R8. |
Hi @Ivanidzo4ka , |
System information
Issue
I was trying to get a better understanding of loading records from a flat file. All I wanted to do was to access the records that have been loaded sequentially and display them.
The code in the while block below is my attempt. This worked well. However, I am wondering if this is the right way to iterate over a cursor? Is there anything simpler to get the individual column values? Feels a bit onerous.
Source code / logs
/*
id|wt|ht|overwt
01|30.0|4.0|False
02|35.0|4.5|False
03|40.0|5.0|False
10|33.0|4.0|True
11|38.0|4.5|True
12|43.0|5.0|True
*/
Please paste or attach the code or logs or traces that would be helpful to diagnose the issue you are reporting.
The text was updated successfully, but these errors were encountered: