Browse Source

Correcting csv authors

main
Jesus 2 years ago
parent
commit
d084fa5120
2 changed files with 16 additions and 7 deletions
  1. +10
    -1
      src/main/java/com/jesuspinar/booksearch/controller/CsvParser.java
  2. +6
    -6
      src/main/resources/books.csv

+ 10
- 1
src/main/java/com/jesuspinar/booksearch/controller/CsvParser.java View File

@ -21,10 +21,19 @@ public class CsvParser {
.skip(1) .skip(1)
.map(line -> { .map(line -> {
String[] values = line.split(separator); String[] values = line.split(separator);
return new Book(values[0], Arrays.asList(values[1].split(listSeparator)), values[2],values[3], values[4]);
if (values.length >= 5) {
return new Book(values[0], Arrays.asList(values[1].split(listSeparator)), values[2], values[3], values[4]);
} else if (values.length == 4){
return new Book(values[0], Arrays.asList(values[1].split(listSeparator)), values[2], values[3], "no publisher");
} else if (values.length == 3){
return new Book(values[0], Arrays.asList(values[1].split(listSeparator)), values[2], "digital", "no publisher");
} else {
return new Book(values[0], Arrays.asList(values[1].split(listSeparator)), "no genre", "digital", "no publisher");
}
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
System.err.println("Error de lectura del fichero de datos: books.csv"); System.err.println("Error de lectura del fichero de datos: books.csv");
System.exit(-1); System.exit(-1);
} }


+ 6
- 6
src/main/resources/books.csv View File

@ -52,7 +52,7 @@ Moon is Down;Steinbeck, John;fiction;196;Penguin
Brethren;Grisham, John;fiction;174;Random House Brethren;Grisham, John;fiction;174;Random House
In a Free State;Naipaul, V. S.;fiction;196;Rupa In a Free State;Naipaul, V. S.;fiction;196;Rupa
Catch 22;Heller, Joseph;fiction;178;Random House Catch 22;Heller, Joseph;fiction;178;Random House
Complete Mastermind;BBC,nonfiction;178;BBC
Complete Mastermind;BBC;nonfiction;178;BBC
Dylan on Dylan;Dylan, Bob;nonfiction;197;Random House Dylan on Dylan;Dylan, Bob;nonfiction;197;Random House
Soft Computing & Intelligent Systems;Gupta, Madan;data science;242;Elsevier Soft Computing & Intelligent Systems;Gupta, Madan;data science;242;Elsevier
Textbook of Economic Theory;Stonier, Alfred;economics;242;Pearson Textbook of Economic Theory;Stonier, Alfred;economics;242;Pearson
@ -79,10 +79,10 @@ Radiowaril Bhashane & Shrutika;Deshpande, P L;nonfiction;213;Mauj
Gun Gayin Awadi;Deshpande, P L;nonfiction;212;Mauj Gun Gayin Awadi;Deshpande, P L;nonfiction;212;Mauj
Aghal Paghal;Deshpande, P L;nonfiction;212;Mauj Aghal Paghal;Deshpande, P L;nonfiction;212;Mauj
Maqta-e-Ghalib;Garg, Sanjay;fiction;221;Mauj Maqta-e-Ghalib;Garg, Sanjay;fiction;221;Mauj
Beyond Degrees ;nonfiction;222;HarperCollins
Beyond Degrees ;no author;nonfiction;222;HarperCollins
Manasa;Kale, V P;nonfiction;213;Mauj Manasa;Kale, V P;nonfiction;213;Mauj
India from Midnight to Milennium;Tharoor, Shashi;history;198;Penguin India from Midnight to Milennium;Tharoor, Shashi;history;198;Penguin
World's Greatest Trials;History;210;
World's Greatest Trials;no author;History;210;
Great Indian Novel;Tharoor, Shashi;fiction;198;Penguin Great Indian Novel;Tharoor, Shashi;fiction;198;Penguin
O Jerusalem!;Lapierre, Dominique;history;217;Vikas O Jerusalem!;Lapierre, Dominique;history;217;Vikas
City of Joy;Lapierre, Dominique;fiction;177;Vikas City of Joy;Lapierre, Dominique;fiction;177;Vikas
@ -102,7 +102,7 @@ Doctor in the Nude;Gordon, Richard;fiction;179;Penguin
Down and Out in Paris & London;Orwell, George;nonfiction;179;Penguin Down and Out in Paris & London;Orwell, George;nonfiction;179;Penguin
Identity & Violence;Sen, Amartya;philosophy;219;Penguin Identity & Violence;Sen, Amartya;philosophy;219;Penguin
Beyond the Three Seas;Dalrymple, William;history;197;Random House Beyond the Three Seas;Dalrymple, William;history;197;Random House
World's Greatest Short Stories;Fiction;217;Jaico
World's Greatest Short Stories;no author;Fiction;217;Jaico
Talking Straight;Iacoca, Lee;nonfiction;175; Talking Straight;Iacoca, Lee;nonfiction;175;
Maugham's Collected Short Stories, Vol 3;Maugham, William S;fiction;171;Vintage Maugham's Collected Short Stories, Vol 3;Maugham, William S;fiction;171;Vintage
Phantom of Manhattan;Forsyth, Frederick;fiction;180; Phantom of Manhattan;Forsyth, Frederick;fiction;180;
@ -112,9 +112,9 @@ Great War for Civilization;Fisk, Robert;history;197;HarperCollins
We the Living;Rand, Ayn;fiction;178;Penguin We the Living;Rand, Ayn;fiction;178;Penguin
Artist and the Mathematician;Aczel, Amir;science;186;HighStakes Artist and the Mathematician;Aczel, Amir;science;186;HighStakes
History of Western Philosophy;Russell, Bertrand;philosophy;213;Routledge History of Western Philosophy;Russell, Bertrand;philosophy;213;Routledge
Selected Short Stories ;Fiction;215;Jaico
Selected Short Stories ;no author;Fiction;215;Jaico
Rationality & Freedom;Sen, Amartya;economics;213;Springer Rationality & Freedom;Sen, Amartya;economics;213;Springer
Clash of Civilizations and Remaking of the World Order;Huntington, Samuel;history;228;Simon&Schuster Clash of Civilizations and Remaking of the World Order;Huntington, Samuel;history;228;Simon&Schuster
Uncommon Wisdom;Capra, Fritjof;nonfiction;197;Fontana Uncommon Wisdom;Capra, Fritjof;nonfiction;197;Fontana
One;Bach, Richard;nonfiction;172;Dell One;Bach, Richard;nonfiction;172;Dell
Karl Marx Biography ;nonfiction;162;
Karl Marx Biography ;no author;nonfiction;162;

Loading…
Cancel
Save