@@ -38,9 +38,9 @@ public FlashcardSetDataAccess(String csvPath) throws IOException {
38
38
39
39
String row ;
40
40
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 ( " \" " , "" ) ;
44
44
boolean privacy = Boolean .parseBoolean (col [headers .get ("isPrivate" )]);
45
45
int id = Integer .parseInt (col [headers .get ("flashcardSetId" )]);
46
46
String ownerUsername = String .valueOf (col [headers .get ("ownerUsername" )]);
@@ -69,7 +69,7 @@ private void save() {
69
69
70
70
for (FlashcardSetDsRequestModel set : flashcardSets .values ()) {
71
71
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 (),
73
73
set .getFlashcardSetId (), set .getOwnerUsername ()));
74
74
for (int flashcardIds : set .getFlashcardIds ()){
75
75
line .append ("," );
0 commit comments