Skip to content

Commit

Permalink
Merge pull request #17 from rollno748/csv-config-2.1
Browse files Browse the repository at this point in the history
Added handling for empty line - Issue-16
  • Loading branch information
rollno748 authored Jan 4, 2024
2 parents d8175dd + 8e78872 commit 2d6f379
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.di.jmeter.ecsv</groupId>
<artifactId>di-extended-csv</artifactId>
<version>2.0</version>
<version>2.1</version>
<!--Properties-->
<properties>
<jmeter-version>5.1.1</jmeter-version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ public void iterationStart(LoopIterationEvent iterationEvent) {
for (int a = 0; a < variables.length && a < lineValues.length; a++) {
jMeterVariables.put(variables[a], lineValues[a]);
}
}else {
for (String variable : variables) {
jMeterVariables.put(variable, null);
}
}
break;
case "once":
Expand Down Expand Up @@ -329,4 +333,4 @@ public void setBlockSize(String blockSize) {
public String printAllProperties() {
return String.format("Filename: %s\n,FileEncoding: %s\n VariableName: %s\n IgnoreFirstLine: %s\n Delimiter: %s\n IsQuotedData: %s\n SelectRow: %s\n UpdateValue: %s\n OOValue: %s\n AutoAllocate: %s\n Allocate: %s\n BlockSize: %s\n",getFilename(),getFileEncoding(),getVariableNames(),isIgnoreFirstLine(),getDelimiter(),isQuotedData(),getSelectRow(),getUpdateValue(),getOoValue(),isAllocate(),isAutoAllocate(),getBlockSize());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ private void init() {
try {
File file = new File(filenameField.getText());
Desktop desktop = Desktop.getDesktop();
if(filenameField.getText().equals("") || filenameField.getText().isEmpty()){
if(filenameField.getText().isEmpty() || filenameField.getText().isEmpty()){
throw new FileNotFoundException();
}
if(!file.exists()){
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/com/di/jmeter/utils/FileServerExtended.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ public class FileServerExtended {

private File base;
private static int rowCount;
private static ThreadLocal<Integer> endPos = new ThreadLocal<>();
private static ThreadLocal<Integer> startPos = new ThreadLocal<>();
private static ThreadLocal<Integer> readPos = new ThreadLocal<>();
private static final ThreadLocal<Integer> endPos = new ThreadLocal<>();
private static final ThreadLocal<Integer> startPos = new ThreadLocal<>();
private static final ThreadLocal<Integer> readPos = new ThreadLocal<>();
private final Map<String, FileEntry> files = new HashMap<>();
private static final FileServerExtended server = new FileServerExtended();

Expand Down Expand Up @@ -591,7 +591,8 @@ public void calculateRowCount(String filename, boolean ignoreFirstLine) {
try (BufferedReader br = new BufferedReader(new FileReader(String.valueOf(fileEntry.file.toPath())))) {
count = (int) br.lines().count();
} catch (IOException e) {
e.printStackTrace();
log.error(e.toString());

}
this.setRowCount(ignoreFirstLine ? count-1 : count );
}
Expand Down

0 comments on commit 2d6f379

Please sign in to comment.