Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
180 changes: 180 additions & 0 deletions data/2026/inscritos.csv

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graphs/2026/Como você se define.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graphs/2026/Como você se identifica.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graphs/2026/Você programa em Python.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graphs/2026/Você trabalha com Python.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,538 changes: 1,100 additions & 438 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ dependencies = [
"rich (>=14.0.0,<15.0.0)",
"dash (>=3.1.0,<4.0.0)",
"dash-bootstrap-components (>=2.0.3,<3.0.0)",
"numpy (>=2.5.2,<3.0.0)",
"matplotlib (>=3.11.1,<4.0.0)",
]

[tool.poetry]
Expand Down
94 changes: 94 additions & 0 deletions scripts/csv-to-graphs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import re
import textwrap

from datetime import date
from pathlib import Path
from matplotlib import pyplot as plt
from pandas import read_csv, DataFrame
from typer import Typer
from rich.console import Console


COLUMNS_TO_EXPORT = [
r'.*python.*',
r'.*identi.*',
r'.*define.*',
r'.*defici.ncia.*',
]

cli = Typer()
console = Console()


def get_columns_to_export(csv: DataFrame):
for column_to_remove in COLUMNS_TO_EXPORT:
for column_name in csv.columns:
if re.match(column_to_remove, column_name, re.IGNORECASE):
yield column_name


@cli.command()
def main(csv: Path, year: int | None = None):
# Reading the CSV file
console.print(f'Reading the file [bold]{csv}[/bold]...')
csv_content = read_csv(csv)

# Reading the year from the CSV file name if not provided
if not year:
if re.match(r'\d{4}', csv.name):
year = int(re.search(r'\d{4}', csv.name).group())
else:
year = date.today().year

# Creating the export folder
export_path = Path(f'graphs/{year}')
export_path.mkdir(parents=True, exist_ok=True)

# Get only the interesting columns to export
columns_to_plot = list(get_columns_to_export(csv_content))
console.print(f'Exporting the columns [bold]{", ".join(columns_to_plot)}[/bold]...')

for column in columns_to_plot:
file = export_path / f'{column.replace("?", "")}.png'
console.print(f'Exporting [bold]{file}[/bold]...')

# Counting the column values
count = csv_content[column].value_counts()

# Formatting the labels to fit in the graph
labels = [
textwrap.fill(str(label), width=15)
for label in count.index
]

plot = count.plot(
kind='bar',
xlabel='',
figsize=(18, 9),
fontsize=16,
color="#0C23F7",
)
plot.bar_label(
plot.containers[0],
labels=count,
fontsize=16,
)

# Adding the formatted labels
plot.set_xticklabels(labels)

# Keep the x-axis labels horizontal
plot.tick_params(
axis='x',
labelrotation=0
)

# Saving the graph to a file
figure = plot.get_figure()
figure.tight_layout()
figure.savefig(file)
plt.close(figure)


if __name__ == '__main__':
cli()
Empty file modified scripts/event3-excel-to-csv.py
100644 → 100755
Empty file.
75 changes: 75 additions & 0 deletions scripts/pretix-excel-to-csv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import re

from pathlib import Path
from pandas import read_excel, DataFrame
from typer import Typer
from rich.console import Console


EMPTY_CELL_TEXT = 'Não respondeu'
SHEET_NAME = 'Posição dos pedidos'
COLUMNS_TO_REMOVE = [
r'.*do.evento',
r'.*do.pedido',
r'.*id\s.*',
r'status',
r'email',
r'.*telefone.*',
r'varia.*o',
r'taxa.*',
r'regra.*',
r'valor.*',
r'nome.do.*',
r'zona.do.*',
r'fileira.do.*',
r'n.mero.do.*',
r'empresa.*',
r'endere.o',
r'c.digo.*',
r'voucher.*',
r'segredo.*',
r'bloqueado',
r'v.lido.*',
r'coment.rio.*',
r'.*fatura.*',
r'.*acompanhamento',
r'.*vendas',
r'.*check-in',
r'.*link.*',
]


cli = Typer()
console = Console()


def get_columns_to_remove(excel_content: DataFrame):
for column_to_remove in COLUMNS_TO_REMOVE:
for column_name in excel_content.columns:
if re.match(column_to_remove, column_name, re.IGNORECASE):
yield column_name


@cli.command()
def convert(excel: Path):
# Reading the Excel file
console.print(f'Reading the file [bold]{excel}[/bold]...')
excel_content = read_excel(excel, sheet_name=SHEET_NAME)

# Removing columns with sensive data
columns_to_remove = list(get_columns_to_remove(excel_content))
console.print(f'Removing columns [bold]{", ".join(columns_to_remove)}[/bold]...')
excel_content.drop(columns=columns_to_remove, inplace=True)

# Filling empty cells with a default text
console.print(f'Filling empty cells...')
excel_content.fillna(EMPTY_CELL_TEXT, inplace=True)

# Writting the output CSV file
output_path = excel.with_suffix('.csv')
console.print(f'Saving data to [bold]{output_path}[/bold]...')
excel_content.to_csv(output_path, index=False)


if __name__ == '__main__':
cli()