Skip to content
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

Some additional methods for ArffReader #1

Open
wvdvegt opened this issue Sep 12, 2019 · 0 comments
Open

Some additional methods for ArffReader #1

wvdvegt opened this issue Sep 12, 2019 · 0 comments

Comments

@wvdvegt
Copy link

wvdvegt commented Sep 12, 2019

In my code i need to know how many instances there are in a file (before enumerating them) to size some multi dimensional arrays.

As the methods get a reader as parameter, there is no way to re-open the reader.

So I added following two methods, to reset the ArffReader's stream and to return the instances count.

        /// <summary>
        /// Reset StreamReader to beginning.
        /// </summary>
        public void Reset()
        {
            streamReader.BaseStream.Position = 0;
            arffHeader = null;
        }

        /// <summary>
        /// Returns the Instance Count.
        /// </summary>
        /// <returns></returns>
        public Int64 Count()
        {
            Reset();
            ReadHeader();
            Int64 count = 0;
            while (ReadInstance() != null)
            {
                count += 1;
            }
            return count;
        }
Repository owner deleted a comment from phuchau1989 Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant