Skip to content

Commit

Permalink
replace separator
Browse files Browse the repository at this point in the history
  • Loading branch information
biancarosa committed Oct 20, 2024
1 parent 47f5ae8 commit 0ac054a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
6 changes: 5 additions & 1 deletion scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@
E use o output para como base para o dicionario de dados ;)

## Columns remover
```python data-cleaner.py remove-columns-cmd ./dados/python-brasil-2024/inscricoes-participantes.csv ./dados/python-brasil-2024/inscricoes-participantes.csv```
```python data-cleaner.py remove-columns-cmd ../dados/python-brasil-2024/inscricoes-participantes.csv ../dados/python-brasil-2024/inscricoes-participantes.csv```

## Replace separator

```python data-cleaner.py replace-separator-cmd ../dados/python-brasil-2024/inscricoes-participantes.csv ../dados/python-brasil-2024/inscricoes-participantes.csv```
20 changes: 19 additions & 1 deletion scripts/data-cleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,25 @@ def normalize_columns_cmd(input_csv, output_csv):
df.to_csv(output_csv, index=False, sep=';', encoding='utf-8')

# Imprimir a tabela Markdown
click.echo(markdown_output)
click.echo(markdown_output)@cli.command()

@cli.command()
@click.argument('input_csv', type=click.Path(exists=True))
@click.argument('output_csv', type=click.Path())
def replace_separator_cmd(input_csv, output_csv):
"""
Normalize column names in the CSV file (lowercase, remove special characters, replace spaces with underscores).
\b
INPUT_CSV: Path to the input CSV file.
OUTPUT_CSV: Path to the output CSV file.
"""
# Read the CSV file
df = pd.read_csv(input_csv, sep=';', na_values=['', ' '], encoding='utf-8')

# Write to the output CSV file quoting values
df.to_csv(output_csv, index=False, sep=',', encoding='utf-8', quotechar='"')


if __name__ == '__main__':
cli()

0 comments on commit 0ac054a

Please sign in to comment.