Java OpenCSV - Ignoring Fields with a Certain Value
up vote
1
down vote
favorite
I'm parsing a dataset that uses N
as an indicator of a null field.
Is there a native-OpenCSV way of handling this?
Currently I am replacing this indicator with empty String before I pass it into the CSVReader using a TranslatingReader.
I have migrated to OpenCSV 4.3.2 and am using CsvToBeanBuilder
as per new best practice.
An excerpt of my code is below although it's not quite an MCVE as I'm sure the answer is as simple as a method I'm missing. But I make one if required.
try (Reader reader = new TranslatingReader(new BufferedReader(new InputStreamReader(new FileInputStream(file))))
{
@Override
public String translate(final String line)
{
return line.replace("\N", "");
}
})
{
return new CsvToBeanBuilder<T>(reader).withType(clazz).build().parse();
}
java opencsv
add a comment |
up vote
1
down vote
favorite
I'm parsing a dataset that uses N
as an indicator of a null field.
Is there a native-OpenCSV way of handling this?
Currently I am replacing this indicator with empty String before I pass it into the CSVReader using a TranslatingReader.
I have migrated to OpenCSV 4.3.2 and am using CsvToBeanBuilder
as per new best practice.
An excerpt of my code is below although it's not quite an MCVE as I'm sure the answer is as simple as a method I'm missing. But I make one if required.
try (Reader reader = new TranslatingReader(new BufferedReader(new InputStreamReader(new FileInputStream(file))))
{
@Override
public String translate(final String line)
{
return line.replace("\N", "");
}
})
{
return new CsvToBeanBuilder<T>(reader).withType(clazz).build().parse();
}
java opencsv
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I'm parsing a dataset that uses N
as an indicator of a null field.
Is there a native-OpenCSV way of handling this?
Currently I am replacing this indicator with empty String before I pass it into the CSVReader using a TranslatingReader.
I have migrated to OpenCSV 4.3.2 and am using CsvToBeanBuilder
as per new best practice.
An excerpt of my code is below although it's not quite an MCVE as I'm sure the answer is as simple as a method I'm missing. But I make one if required.
try (Reader reader = new TranslatingReader(new BufferedReader(new InputStreamReader(new FileInputStream(file))))
{
@Override
public String translate(final String line)
{
return line.replace("\N", "");
}
})
{
return new CsvToBeanBuilder<T>(reader).withType(clazz).build().parse();
}
java opencsv
I'm parsing a dataset that uses N
as an indicator of a null field.
Is there a native-OpenCSV way of handling this?
Currently I am replacing this indicator with empty String before I pass it into the CSVReader using a TranslatingReader.
I have migrated to OpenCSV 4.3.2 and am using CsvToBeanBuilder
as per new best practice.
An excerpt of my code is below although it's not quite an MCVE as I'm sure the answer is as simple as a method I'm missing. But I make one if required.
try (Reader reader = new TranslatingReader(new BufferedReader(new InputStreamReader(new FileInputStream(file))))
{
@Override
public String translate(final String line)
{
return line.replace("\N", "");
}
})
{
return new CsvToBeanBuilder<T>(reader).withType(clazz).build().parse();
}
java opencsv
java opencsv
asked Nov 10 at 17:33
Jakg
306110
306110
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f53241616%2fjava-opencsv-ignoring-fields-with-a-certain-value%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