考虑退房
convtools
图书馆:
# inputs
input_file = "tmp/input.csv"
column = "Price"
left_bound = 100
right_bound = 202
rows = (
# read csv file, use header as column names
Table.from_csv(input_file, header=True)
# cast column values to int
.update(**{column: c.col(column).as_type(int)}).into_iter_rows(dict)
)
converter = (
# this one lets the left bound in, it is to be skipped
c.drop_while(c.item(column) != left_bound)
.take_while(c.item(column) != right_bound)
.gen_converter()
)
filtered_rows = iter(converter(rows))
try:
# skipping the left bound
next(filtered_rows)
except StopIteration:
print("no rows")
else:
for row in filtered_rows:
print(row)