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
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
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
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
asked Nov 21 at 22:37
Ignorant Fanatic
1
1
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
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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