sync_v2
Laurent 6 months ago
parent 92e50b55dd
commit ba4f6652ed
  1. 5
      api/views.py

@ -429,10 +429,11 @@ def xls_to_csv(request):
data_xls = pd.read_excel(full_path, sheet_name=target_sheet, index_col=None)
csv_file_name = create_random_filename('players', 'csv')
output_path = os.path.join(directory, csv_file_name)
data_xls.to_csv(output_path, sep=';', index=False, encoding='utf-8')
full_output_path = default_storage.path(output_path)
data_xls.to_csv(full_output_path, sep=';', index=False, encoding='utf-8')
# Send the processed file back
with default_storage.open(output_path, 'rb') as file:
with default_storage.open(full_output_path, 'rb') as file:
response = HttpResponse(file.read(), content_type='application/octet-stream')
response['Content-Disposition'] = f'attachment; filename="players.csv"'

Loading…
Cancel
Save