Skip to content

Commit

Permalink
updated timestamp column finding
Browse files Browse the repository at this point in the history
  • Loading branch information
camdnnn committed Apr 28, 2024
1 parent 6f11596 commit 9c84dce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.DoubleSummaryStatistics;
import java.util.Locale;
import java.util.NoSuchElementException;
Expand Down Expand Up @@ -91,7 +92,7 @@ public Double[] getMinMax(Path targetPath, String column) {
}
}

public String getLast(Path targetPath, String column) {
public String getLast(Path targetPath, int columnIndex) {

String timestamp;

Expand All @@ -102,7 +103,7 @@ public String getLast(Path targetPath, String column) {
.setCharset(StandardCharsets.UTF_8)
.get();

timestamp = reverseReader.readLine().split(",")[0];
timestamp = reverseReader.readLine().split(",")[columnIndex];
reverseReader.close();
} catch (IOException e) {
throw new FileNotFoundException("Failed to get last of file: " + targetPath.toString(), e);
Expand Down Expand Up @@ -228,9 +229,10 @@ private LocalDateTime[] getTimespanCSV(Path targetPath, LocalDateTime zeroTime)
try {
BufferedReader reader =
new BufferedReader(Files.newBufferedReader(storageService.load(targetPath)));
firstTimestamp = reader.lines().skip(1).findFirst().orElseThrow().split(",")[0];
int timestampIndex = Arrays.asList(reader.readLine().split(",")).indexOf("Timestamp (ms)");
firstTimestamp = reader.readLine().split(",")[timestampIndex];
reader.close();
lastTimestamp = getLast(targetPath, "Timestamp (ms)");
lastTimestamp = getLast(targetPath, timestampIndex);
} catch (IOException e) {
throw new FileNotFoundException(
"Failed to get timespan of file: " + targetPath.toString(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public interface FileMetadataService {
* @param targetPath The Path of the file to read.
* @return The last value of the column
*/
String getLast(Path targetPath, String column);
String getLast(Path targetPath, int columnIndex);

/**
* Checks if the timespan of a folder can be computed.
Expand Down

0 comments on commit 9c84dce

Please sign in to comment.