У меня есть файл .tsv, который имеет 39 столбцов, последний, но один столбец содержит данные в виде строки, длина которой превышает 100 000 символов. Теперь происходит, когда я пытаюсь прочитать строку файла 1 имеет заголовки, а затем следуют данные
Что происходит, так это то, что после чтения строки 1 он переходит к строке 3, затем к строке 5, затем к строке 7. Хотя все строки имеют одинаковые данные. Следуя журналу, я получаю
lineNo=3, rowNo=2, customer=503837-100 , last but one cell length=111275
lineNo=5, rowNo=3, customer=503837-100 , last but one cell length=111275
lineNo=7, rowNo=4, customer=503837-100 , last but one cell length=111275
lineNo=9, rowNo=5, customer=503837-100 , last but one cell length=111275
lineNo=11, rowNo=6, customer=503837-100 , last but one cell length=111275
lineNo=13, rowNo=7, customer=503837-100 , last but one cell length=111275
lineNo=15, rowNo=8, customer=503837-100 , last but one cell length=111275
lineNo=17, rowNo=9, customer=503837-100 , last but one cell length=111275
lineNo=19, rowNo=10, customer=503837-100 , last but one cell length=111275
Ниже приведен мой код:
import java.io.FileReader;
import org.supercsv.cellprocessor.Optional;
import org.supercsv.cellprocessor.constraint.NotNull;
import org.supercsv.cellprocessor.ift.CellProcessor;
import org.supercsv.io.CsvBeanReader;
import org.supercsv.io.ICsvBeanReader;
import org.supercsv.prefs.CsvPreference;
public class readWithCsvBeanReader {
public static void main(String[] args) throws Exception{
readWithCsvBeanReader();
}
private static void readWithCsvBeanReader() throws Exception {
ICsvBeanReader beanReader = null;
try {
beanReader = new CsvBeanReader(new FileReader("C:\MAP TSV\abc.tsv"), CsvPreference.TAB_PREFERENCE);
// the header elements are used to map the values to the bean (names must match)
final String[] header = beanReader.getHeader(true);
final CellProcessor[] processors = getProcessors();
TSVReaderBrandDTO tsvReaderBrandDTO = new TSVReaderBrandDTO();
int i = 0;
int last = 0;
while( (tsvReaderBrandDTO = beanReader.read(TSVReaderBrandDTO.class, header, processors)) != null ) {
if(null == tsvReaderBrandDTO.getPage_cache()){
last = 0;
}
else{
last = tsvReaderBrandDTO.getPage_cache().length();
}
System.out.println(String.format("lineNo=%s, rowNo=%s, customer=%s , last but one cell length=%s", beanReader.getLineNumber(),
beanReader.getRowNumber(), tsvReaderBrandDTO.getUnique_ID(), last));
i++;
}
System.out.println("Number of rows : "+i);
}
finally {
if( beanReader != null ) {
beanReader.close();
}
}
}
private static CellProcessor[] getProcessors() {
final CellProcessor[] processors = new CellProcessor[] {
new Optional(), new NotNull(), new NotNull(), new NotNull(), new NotNull(),
new NotNull(), new NotNull(), new NotNull(), new NotNull(), new NotNull(),
new NotNull(), new NotNull(), new NotNull(), new NotNull(), new NotNull(),
new NotNull(), new NotNull(), new NotNull(), new NotNull(), new NotNull(),
new NotNull(), new NotNull(), new NotNull(), new NotNull(), new NotNull(),
new NotNull(), new NotNull(), new NotNull(), new NotNull(), new NotNull(),
new NotNull(), new NotNull(), new NotNull(), new NotNull(), new NotNull(),
new NotNull(), new NotNull(), new NotNull(), new Optional()};
return processors;
}
}
Пожалуйста, дайте мне знать, где я ошибаюсь