Skip to content

Commit 41a28f9

Browse files
committed
fixed bug for flashcard set title and descriptions
1 parent 26c45bd commit 41a28f9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/java/frameworks_and_drivers/database/FlashcardSetDataAccess.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ public FlashcardSetDataAccess(String csvPath) throws IOException {
3838

3939
String row;
4040
while ((row = reader.readLine()) != null) {
41-
String[] col = row.split(",");
42-
String title = String.valueOf(col[headers.get("title")]);
43-
String description = String.valueOf(col[headers.get("description")]);
41+
String[] col = row.split(",(?=([^\"]|\"[^\"]*\")*$)");
42+
String title = String.valueOf(col[headers.get("title")]).replace("\"","");
43+
String description = String.valueOf(col[headers.get("description")]).replace("\"","");
4444
boolean privacy = Boolean.parseBoolean(col[headers.get("isPrivate")]);
4545
int id = Integer.parseInt(col[headers.get("flashcardSetId")]);
4646
String ownerUsername = String.valueOf(col[headers.get("ownerUsername")]);
@@ -69,7 +69,7 @@ private void save() {
6969

7070
for (FlashcardSetDsRequestModel set : flashcardSets.values()) {
7171
StringBuilder line = new StringBuilder(String.
72-
format("%s,%s,%s,%s,%s", set.getTitle(), set.getDescription(), set.getIsPrivate(),
72+
format("\"%s\",\"%s\",%s,%s,%s", set.getTitle(), set.getDescription(), set.getIsPrivate(),
7373
set.getFlashcardSetId(), set.getOwnerUsername()));
7474
for(int flashcardIds : set.getFlashcardIds()){
7575
line.append(",");

0 commit comments

Comments
 (0)