Skip to content

Commit

Permalink
Merge pull request #59 from Yamato-Security/58-fix-progress-number
Browse files Browse the repository at this point in the history
fix: increment count for last line without `\n`
  • Loading branch information
YamatoSecurity authored Oct 23, 2023
2 parents 66525e6 + f5e9457 commit 4f77848
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 1 addition & 7 deletions src/takajopkg/general.nim
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,6 @@ proc elevatedTokenIdToName*(elevatedTokenId: string): string =
return result

proc countLinesInTimeline*(filePath: string): int =
#[
var count = 0
for _ in filePath.lines():
inc count
return count
]#
const BufferSize = 4 * 1024 * 1024 # 4 MiB
var buffer = newString(BufferSize)
var file = open(filePath)
Expand All @@ -232,7 +226,7 @@ proc countLinesInTimeline*(filePath: string): int =
for i in 0 ..< bytesRead:
if buffer[i] == '\n':
inc(count)

inc(count)
file.close()
return count

Expand Down
2 changes: 2 additions & 0 deletions src/takajopkg/splitCsvTimeline.nim
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ proc splitCsvTimeline(makeMultiline: bool = false, output: string = "output", qu

# Read in the CSV header
let csvHeader = inputFile.readLine()
inc bar
while inputFile.endOfFile == false:
inc bar
bar.update(1000000000) # refresh every second
Expand Down Expand Up @@ -67,6 +68,7 @@ proc splitCsvTimeline(makeMultiline: bool = false, output: string = "output", qu
outputFile.write(currentLine)
outputFile.write("\p")
flushFile(outputFile)
inc bar
bar.finish()

# Close all opened files
Expand Down

0 comments on commit 4f77848

Please sign in to comment.