Skip to content

Commit 0d08506

Browse files
author
hare
committed
lint fix
1 parent 2b3361f commit 0d08506

File tree

1 file changed

+48
-9
lines changed
  • dataframe-excel/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io

1 file changed

+48
-9
lines changed

dataframe-excel/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/xlsx.kt

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,16 @@ public fun DataFrame.Companion.readExcel(
112112
setWorkbookTempDirectory()
113113
val wb = WorkbookFactory.create(url.openStream())
114114
return wb.use {
115-
readExcel(wb, sheetName, skipRows, columns, stringColumns?.toFormattingOptions(), rowsCount, nameRepairStrategy, withDefaultHeader)
115+
readExcel(
116+
wb,
117+
sheetName,
118+
skipRows,
119+
columns,
120+
stringColumns?.toFormattingOptions(),
121+
rowsCount,
122+
nameRepairStrategy,
123+
withDefaultHeader,
124+
)
116125
}
117126
}
118127

@@ -143,7 +152,16 @@ public fun DataFrame.Companion.readExcel(
143152
setWorkbookTempDirectory()
144153
val wb = WorkbookFactory.create(file)
145154
return wb.use {
146-
readExcel(it, sheetName, skipRows, columns, stringColumns?.toFormattingOptions(), rowsCount, nameRepairStrategy, withDefaultHeader)
155+
readExcel(
156+
it,
157+
sheetName,
158+
skipRows,
159+
columns,
160+
stringColumns?.toFormattingOptions(),
161+
rowsCount,
162+
nameRepairStrategy,
163+
withDefaultHeader,
164+
)
147165
}
148166
}
149167

@@ -172,7 +190,17 @@ public fun DataFrame.Companion.readExcel(
172190
rowsCount: Int? = null,
173191
nameRepairStrategy: NameRepairStrategy = NameRepairStrategy.CHECK_UNIQUE,
174192
withDefaultHeader: Boolean = false,
175-
): AnyFrame = readExcel(asURL(fileOrUrl), sheetName, skipRows, columns, stringColumns, rowsCount, nameRepairStrategy, withDefaultHeader)
193+
): AnyFrame =
194+
readExcel(
195+
asURL(fileOrUrl),
196+
sheetName,
197+
skipRows,
198+
columns,
199+
stringColumns,
200+
rowsCount,
201+
nameRepairStrategy,
202+
withDefaultHeader,
203+
)
176204

177205
/**
178206
* @param sheetName sheet to read. By default, the first sheet in the document
@@ -201,7 +229,16 @@ public fun DataFrame.Companion.readExcel(
201229
setWorkbookTempDirectory()
202230
val wb = WorkbookFactory.create(inputStream)
203231
return wb.use {
204-
readExcel(it, sheetName, skipRows, columns, stringColumns?.toFormattingOptions(), rowsCount, nameRepairStrategy, withDefaultHeader)
232+
readExcel(
233+
it,
234+
sheetName,
235+
skipRows,
236+
columns,
237+
stringColumns?.toFormattingOptions(),
238+
rowsCount,
239+
nameRepairStrategy,
240+
withDefaultHeader,
241+
)
205242
}
206243
}
207244

@@ -279,15 +316,17 @@ public fun DataFrame.Companion.readExcel(
279316
nameRepairStrategy: NameRepairStrategy = NameRepairStrategy.CHECK_UNIQUE,
280317
withDefaultHeader: Boolean = false,
281318
): AnyFrame {
282-
val columnIndexes: Iterable<Int> = when{
319+
val columnIndexes: Iterable<Int> = when {
283320
withDefaultHeader -> {
284321
val notEmptyRow = sheet.rowIterator().asSequence().find { it != null }
285-
checkNotNull(notEmptyRow){
322+
checkNotNull(notEmptyRow) {
286323
"There are no defined cells"
287324
}
288325
notEmptyRow.firstCellNum until notEmptyRow.lastCellNum
289326
}
327+
290328
columns != null -> getColumnIndices(columns)
329+
291330
else -> {
292331
val headerRow = checkNotNull(sheet.getRow(skipRows)) {
293332
"Row number ${skipRows + 1} (1-based index) is not defined on the sheet ${sheet.sheetName}"
@@ -300,10 +339,10 @@ public fun DataFrame.Companion.readExcel(
300339
}
301340
}
302341

303-
val headerRow: Row? = if(withDefaultHeader){
342+
val headerRow: Row? = if (withDefaultHeader) {
304343
sheet.shiftRows(0, sheet.lastRowNum, 1)
305344
sheet.createRow(0)
306-
}else{
345+
} else {
307346
sheet.getRow(skipRows)
308347
}
309348

@@ -324,7 +363,7 @@ public fun DataFrame.Companion.readExcel(
324363
val name = repairNameIfRequired(
325364
nameFromCell,
326365
columnNameCounters,
327-
if (withDefaultHeader) NameRepairStrategy.MAKE_UNIQUE else nameRepairStrategy
366+
if (withDefaultHeader) NameRepairStrategy.MAKE_UNIQUE else nameRepairStrategy,
328367
)
329368
columnNameCounters[nameFromCell] =
330369
columnNameCounters.getOrDefault(nameFromCell, 0) + 1 // increase the counter for specific column name

0 commit comments

Comments
 (0)