Skip to content

Commit

Permalink
feat: add choice of number of rows
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoBousseau committed Aug 1, 2022
1 parent 2ec648b commit d168fa7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/data_selector/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ def version():
default=',',
help="File separator (csv).",
)
@click.option(
"-r",
"--nbOfRows",
"nb_rows",
type=int,
required=False,
default=10,
help="Number of rows to import from input_file.",
)
@click.option(
"-S",
"--select",
Expand Down Expand Up @@ -101,6 +110,7 @@ def select_cli(
path_columns_to_delete: str,
path_to_data_and_columns: str,
file_sep: str,
nb_rows: int,
data_frame=None
):
"""Start service to select Data to Keep/Delete"""
Expand All @@ -110,11 +120,12 @@ def select_cli(
overwrite,
file_format_in,
file_format_out,
nb_rows,
path_columns_to_keep,
path_columns_to_delete,
path_to_data_and_columns,
file_sep,
data_frame
data_frame=data_frame
)


Expand Down
4 changes: 3 additions & 1 deletion src/data_selector/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def select(
overwrite: bool,
input_format: str,
format_choice: str,
nb_rows=1000,
path_columns_to_keep=None,
path_columns_to_delete=None,
path_to_data_and_columns=None,
Expand All @@ -26,7 +27,7 @@ def select(
user for the choices.
"""
if data_frame is None:
data_frame = pd.read_csv(input_file)
data_frame = pd.read_csv(input_file, nrows=nb_rows, engine='python', sep=file_sep)

print("\nINPUT :\n" + str(len(data_frame)) + " rows")
print(str(len(data_frame.columns)) + " columns")
Expand Down Expand Up @@ -184,6 +185,7 @@ def select_data_and_column(
for column in param_dict['column_names'].keys():
for val in param_dict["column_names"][column]['value']:
list_inter_value.append(data_frame[data_frame[column] == val])
print(val)
list_inter_column.append(pd.concat(list_inter_value))
list_inter_value = []

Expand Down

0 comments on commit d168fa7

Please sign in to comment.