Re-reading CSV method for bufferedSource
up vote
0
down vote
favorite
I'm trying to read a csv and gather two types of informations.
I need to read it once to get the number of lines that my csv contains.
I need to go back to the top of the csv and re read it again to retrieve the values.
I'm looking for something similar to seek(0) in java for bufferedSource
I've tried to close and re open the buffer but I think I'm overthiking it.
I also read through the source library but nothing came close to what I'm looking for.
PS:I know this is not optimized however my first read will basically enable me to create an array to store the values I'd retrive from the second read(and not a list).
I would take any clue you might have to offer !
Thanks a lot
scala
New contributor
add a comment |
up vote
0
down vote
favorite
I'm trying to read a csv and gather two types of informations.
I need to read it once to get the number of lines that my csv contains.
I need to go back to the top of the csv and re read it again to retrieve the values.
I'm looking for something similar to seek(0) in java for bufferedSource
I've tried to close and re open the buffer but I think I'm overthiking it.
I also read through the source library but nothing came close to what I'm looking for.
PS:I know this is not optimized however my first read will basically enable me to create an array to store the values I'd retrive from the second read(and not a list).
I would take any clue you might have to offer !
Thanks a lot
scala
New contributor
You might start with a CSV processing library. You don't want to do this yourself.
– erip
Nov 21 at 23:00
Why not just.fromFile("...").getLines().toArray
?
– jwvh
Nov 21 at 23:07
I will look into the option suggested above. And I must do it on my own which means no spark scala and such..
– Ignorant Fanatic
Nov 21 at 23:24
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm trying to read a csv and gather two types of informations.
I need to read it once to get the number of lines that my csv contains.
I need to go back to the top of the csv and re read it again to retrieve the values.
I'm looking for something similar to seek(0) in java for bufferedSource
I've tried to close and re open the buffer but I think I'm overthiking it.
I also read through the source library but nothing came close to what I'm looking for.
PS:I know this is not optimized however my first read will basically enable me to create an array to store the values I'd retrive from the second read(and not a list).
I would take any clue you might have to offer !
Thanks a lot
scala
New contributor
I'm trying to read a csv and gather two types of informations.
I need to read it once to get the number of lines that my csv contains.
I need to go back to the top of the csv and re read it again to retrieve the values.
I'm looking for something similar to seek(0) in java for bufferedSource
I've tried to close and re open the buffer but I think I'm overthiking it.
I also read through the source library but nothing came close to what I'm looking for.
PS:I know this is not optimized however my first read will basically enable me to create an array to store the values I'd retrive from the second read(and not a list).
I would take any clue you might have to offer !
Thanks a lot
scala
scala
New contributor
New contributor
New contributor
asked Nov 21 at 22:37
Ignorant Fanatic
1
1
New contributor
New contributor
You might start with a CSV processing library. You don't want to do this yourself.
– erip
Nov 21 at 23:00
Why not just.fromFile("...").getLines().toArray
?
– jwvh
Nov 21 at 23:07
I will look into the option suggested above. And I must do it on my own which means no spark scala and such..
– Ignorant Fanatic
Nov 21 at 23:24
add a comment |
You might start with a CSV processing library. You don't want to do this yourself.
– erip
Nov 21 at 23:00
Why not just.fromFile("...").getLines().toArray
?
– jwvh
Nov 21 at 23:07
I will look into the option suggested above. And I must do it on my own which means no spark scala and such..
– Ignorant Fanatic
Nov 21 at 23:24
You might start with a CSV processing library. You don't want to do this yourself.
– erip
Nov 21 at 23:00
You might start with a CSV processing library. You don't want to do this yourself.
– erip
Nov 21 at 23:00
Why not just
.fromFile("...").getLines().toArray
?– jwvh
Nov 21 at 23:07
Why not just
.fromFile("...").getLines().toArray
?– jwvh
Nov 21 at 23:07
I will look into the option suggested above. And I must do it on my own which means no spark scala and such..
– Ignorant Fanatic
Nov 21 at 23:24
I will look into the option suggested above. And I must do it on my own which means no spark scala and such..
– Ignorant Fanatic
Nov 21 at 23:24
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Ignorant Fanatic is a new contributor. Be nice, and check out our Code of Conduct.
Ignorant Fanatic is a new contributor. Be nice, and check out our Code of Conduct.
Ignorant Fanatic is a new contributor. Be nice, and check out our Code of Conduct.
Ignorant Fanatic is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421401%2fre-reading-csv-method-for-bufferedsource%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You might start with a CSV processing library. You don't want to do this yourself.
– erip
Nov 21 at 23:00
Why not just
.fromFile("...").getLines().toArray
?– jwvh
Nov 21 at 23:07
I will look into the option suggested above. And I must do it on my own which means no spark scala and such..
– Ignorant Fanatic
Nov 21 at 23:24