Skip to content

Commit

Permalink
Fix issue #128
Browse files Browse the repository at this point in the history
  • Loading branch information
tah5in committed Apr 15, 2024
1 parent 98266da commit 9b96d5c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/scm/address/logic/commands/ImportCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,19 @@ private List<JsonAdaptedPerson> readPersonsFromCsv(File file) throws DataLoading
* @return A List of JsonAdaptedPerson present inside the {@code file}.
* @throws IOException If the {@code file} is unable to be loaded.
*/
private List<JsonAdaptedPerson> getPersonsFromCsv(String filePath) throws IOException {
private List<JsonAdaptedPerson> getPersonsFromCsv(String filePath) throws IOException, DataLoadingException {
List<JsonAdaptedPerson> persons = new ArrayList<>();
BufferedReader br = new BufferedReader(new FileReader(filePath));
String line = "";
String splitBy = ",(?=([^\"]*\"[^\"]*\")*[^\"]*$)";
String headers = br.readLine();
while ((line = br.readLine()) != null) {
String[] info = line.split(splitBy);

if (info.length < 4) {
throw new IOException("Incorrect Data Format!");

Check warning on line 195 in src/main/java/scm/address/logic/commands/ImportCommand.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/scm/address/logic/commands/ImportCommand.java#L195

Added line #L195 was not covered by tests
}

String name = info[0];
String phone = info[1];
String email = info[2];
Expand Down

0 comments on commit 9b96d5c

Please sign in to comment.