Re: my excel file is not updated to add new data

2023-06-26 Thread dn via Python-list

Marc,

Apologies for writing in English (the language of this Discussion List). 
I have attempted to keep the code in French...


Thanks for this question. If it's OK with you, I would like to use it as 
an example-problem (and 'solution') challenge for some future Python 
Users' Group meeting (suitably translated, etc)...



On 27/06/2023 05.46, small marcc via Python-list wrote:


This code creates the path to the Excel file where the data will be written. It 
checks if the file already exists, and if so, reads the existing data into a 
DataFrame. Otherwise, it creates a new empty DataFrame. Then it concatenates 
the existing data with the new data and writes the result to the Excel file. 
Finally, it displays a message that the backup was successful and closes the 
information window.

I do not understand why it does not work, the new data is not displayed in 
excel when I am in python tkinter, my data in python must be displayed in excel.
I use the following code to write data to an excel file using pandas:

please help meHowever, when I run this code, the new data is not showing in the 
excel file. I don't understand why this isn't working. Can you help me solve 
this problem?


Is this a Python problem, or a problem with the way the solution has 
been coded?


There are several steps in the solution-description. It is troubling (to 
both of us) that you are unable to locate the source of the error. Why? 
Because it is not noticed until the final stage "new data is not displayed"!


NB am ignoring that the line defining "df" and everything thereafter, 
appears to be incorrectly indented - when viewed in my email-client. 
That said, the sequence of events seems muddled.



Please review the code. Compare it to the verbal/English-language 
description of the solution. Can each sentence in the solution be easily 
identified in the code?


Words like "and", "otherwise", "then", and "finally" indicate that there 
are multiple steps in the process. Let's split the separate sentences 
and phrases:


- creates the path to the Excel file where the data will be written
- checks if the file already exists
[establish DataFrame]
  - if so, reads the existing data into a DataFrame
  - Otherwise, it creates a new empty DataFrame
- concatenates the existing data with the new data
- writes the result to the Excel file
- displays a message that the backup was successful
- closes the information window.

NB addition of a task-label summarising the two DataFrame alternative 
situations.



Now, we can outline the Python code by writing a bunch of function 
definitions:


def create_data_path():
def check_for_file():
def establish_data_frame():
  def read_existing_data():
  def create_new_data_frame():
def accept_new_data():
def save_to_file():
def report():
def terminate():

NB my IDE would grumble and complain if I did this 'for real'. In a 'new 
code' situation, you may like to add a pass-statement inside each, and 
vertical-spacing to make the distracting-complaints 'go away'. 
Alternately and assuming the function-name doesn't say it all, add a 
docstring (you're going to add one anyway, right?) and expand upon the 
function-name with some explanation of what the function will do. In 
this situation, you could add the existing code.


NBB the two sub-tasks have been indented here for continuity of flow. 
They may/may not be nested within establish_data_frame() when you detail 
the content of each function - not important to this outline.


NBBB I've quickly drafted function-names for the sake of this 
discussion. I find it easier to name things when it is time to use them 
(in this case, call the function). Fortunately, a competent IDE will 
facilitate the refactoring of names ("symbols"). Yes, doing it that way 
costs (me) little extra effort - but it saves straining my brain 
up-front. That said, investing time in 'designing' a good name, will 
also tend to clarify and sharpen one's thinking. So, apparently I follow 
both paths... YMMV!



Now that the solution has been outlined, one can consider what output 
you expect from each function, what input it will require to produce 
that, and the transformation in-between. For example:


def create_data_path( nom_fichier ):
* copy existing code into here
return chemin_fichier_excel

(pausing at the one function, for now...)

[for non-French speakers:
nom_fichier = file_name
chemin_fichier_excel = data path including file-name
]


How has this design-process improved things?

1 clearer thinking: we have a simple and more straightforward idea of 
what should happen
2 "separation of concerns": each function does one job (and should do it 
well!)
3 testability: we can now ensure that the (each) function performs 
correctly (in isolation)
4 the problem of locating the source of an error is simplified (in fact, 
the "testability" advantage may solve this problem - or in a new-design 
situation, avoid it*)



Testing the function is carried-out by calling the 

Re: my excel file is not updated to add new data

2023-06-26 Thread Thomas Passin via Python-list

On 6/26/2023 1:46 PM, small marcc via Python-list wrote:

pandas.ExcelWriter

import pandas

This code creates the path to the Excel file where the data will be written. It 
checks if the file already exists, and if so, reads the existing data into a 
DataFrame. Otherwise, it creates a new empty DataFrame. Then it concatenates 
the existing data with the new data and writes the result to the Excel file. 
Finally, it displays a message that the backup was successful and closes the 
information window.

I do not understand why it does not work, the new data is not displayed in 
excel when I am in python tkinter, my data in python must be displayed in excel.
I use the following code to write data to an excel file using pandas:

please help meHowever, when I run this code, the new data is not showing in the 
excel file.


Do you meant the modified data is not displayed in a linked Excel 
window, or that the Excel file itself does not get changed?



I don't understand why this isn't working. Can you help me solve this problem?

data = {'Numero du client': [numero_du_client],
 'Prénom': [prenom],
 'Nom': [nom],
 'Adresse': [adresse],
 'Numero de téléphone': [numero_de_tel],
 'Longueur de cour': [longueur_de_cour],
 'Largeur de cour': [largeur_de_cour],
 "Unite(p ou m)":[boutonPieds, boutonMetres] #edit
 "Prix_coutant:[prix_coutant],   #new add  he asks me to define when I 
haven't done for others
 "Prix soumission":[prix_soumission], # new add  he asks me to define when 
I haven't done for others
 "MargeProfit":[marge_profit]} # new dd   he asks me to define when I 
haven't done for others


#my link with live excel valid for any move as long as the script and excel are 
in the same folder


chemin_script = os.path.abspath(__file__)
dossier_script = os.path.dirname(chemin_script)
nom_fichier_excel = "testpython.xlsx"
chemin_fichier_excel = os.path.join(dossier_script, nom_fichier_excel)
  df = pd.DataFrame(data)
 if os.path.exists(chemin_fichier_excel):
  df_existant = pd.read_excel(chemin_fichier_excel)
 else:
  df_existant = pd.DataFrame()
 df_concat = pd.concat([df_existant, df], ignore_index=True)
 df_concat.to_excel(chemin_fichier_excel, index=False)
 with pd.ExcelWriter(path, engine='xlsxwriter') as writer:
  df.to_excel(writer, index=False, sheet_name='Clients')
 print("sauvegarde reussi")
 fenetre_info.destroy()



--
https://mail.python.org/mailman/listinfo/python-list


my excel file is not updated to add new data

2023-06-26 Thread small marcc via Python-list
pandas.ExcelWriter

import pandas

This code creates the path to the Excel file where the data will be written. It 
checks if the file already exists, and if so, reads the existing data into a 
DataFrame. Otherwise, it creates a new empty DataFrame. Then it concatenates 
the existing data with the new data and writes the result to the Excel file. 
Finally, it displays a message that the backup was successful and closes the 
information window.

I do not understand why it does not work, the new data is not displayed in 
excel when I am in python tkinter, my data in python must be displayed in excel.
I use the following code to write data to an excel file using pandas:

please help meHowever, when I run this code, the new data is not showing in the 
excel file. I don't understand why this isn't working. Can you help me solve 
this problem?

data = {'Numero du client': [numero_du_client],
'Prénom': [prenom],
'Nom': [nom],
'Adresse': [adresse],
'Numero de téléphone': [numero_de_tel],
'Longueur de cour': [longueur_de_cour],
'Largeur de cour': [largeur_de_cour],
"Unite(p ou m)":[boutonPieds, boutonMetres] #edit
"Prix_coutant:[prix_coutant],   #new add  he asks me to define when I 
haven't done for others
"Prix soumission":[prix_soumission], # new add  he asks me to define when I 
haven't done for others
"MargeProfit":[marge_profit]} # new dd   he asks me to define when I 
haven't done for others


#my link with live excel valid for any move as long as the script and excel are 
in the same folder


chemin_script = os.path.abspath(__file__)
dossier_script = os.path.dirname(chemin_script)
nom_fichier_excel = "testpython.xlsx"
chemin_fichier_excel = os.path.join(dossier_script, nom_fichier_excel)
 df = pd.DataFrame(data)
if os.path.exists(chemin_fichier_excel):
 df_existant = pd.read_excel(chemin_fichier_excel)
else:
 df_existant = pd.DataFrame()
df_concat = pd.concat([df_existant, df], ignore_index=True)
df_concat.to_excel(chemin_fichier_excel, index=False)
with pd.ExcelWriter(path, engine='xlsxwriter') as writer:
 df.to_excel(writer, index=False, sheet_name='Clients')
print("sauvegarde reussi")
fenetre_info.destroy()

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: unable to run the basic Embedded Python example

2023-06-26 Thread Christian Gollwitzer via Python-list

Hi Dave,

I can tell you where the error comes from, but I don't know how to fix 
it correctly:


Am 24.06.23 um 19:29 schrieb Dave Ohlsson:

9. And now, when I ran embedded_python.exe:

20:14:06: Starting
C:\temp\build-embedded_python-Desktop_Qt_6_1_3_MSVC2019_64bit-Debug\debug\embedded_python.exe...
Could not find platform independent libraries 
Python path configuration:
   PYTHONHOME = (not set)
   PYTHONPATH = (not set)
   program name =



Python consists of the DLL that you have lined it with plus a large 
number of files (standard library) which contain, e.g., the encoding 
data and builtin functions etc. It needs to find these in order to run. 
You could set PYTHONHOME as an environment variable to point to that 
folder. If you don't use the regular Pyton installer, then you need to 
install these files yourself. Maybe there is also a way to set it from 
the C code.


Christian
--
https://mail.python.org/mailman/listinfo/python-list


[Python-announce] Release of NumPy 1.24. 4

2023-06-26 Thread Charles R Harris
Hi All,

On behalf of the NumPy team, I'm pleased to announce the release of NumPy
1.24.4. NumPy 1.24.4 is a maintenance release that fixes a few bugs
discovered after the 1.24.3 release.

The Python versions supported by this release are 3.8-3.11 Note that 32 bit
wheels are only provided for Windows, all other wheels are 64 bits on
account of Ubuntu, Fedora, and other Linux distributions dropping 32 bit
support. Wheels can be downloaded from PyPI
; source archives, release notes,
and wheel hashes are available on Github
.


*Contributors*

A total of 4 people contributed to this release.  People with a "+" by
their names contributed a patch for the first time.

   - Bas van Beek
   - Charles Harris
   - Sebastian Berg
   - Hongyang Peng +



*Pull requests merged*
A total of 6 pull requests were merged for this release.

   - #23720: MAINT, BLD: Pin rtools to version 4.0 for Windows builds.
   - #23739: BUG: fix the method for checking local files for 1.24.x
   - #23760: MAINT: Copy rtools installation from install-rtools.
   - #23761: BUG: Fix masked array ravel order for A (and somewhat K)
   - #23890: TYP,DOC: Annotate and document the ``metadata`` parameter of...
   - #23994: MAINT: Update rtools installation


Cheers,

Charles Harris
___
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/
Member address: arch...@mail-archive.com


[Python-announce] magic-folder 23.6.0

2023-06-26 Thread meejah


-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

Greetings,

We are pleased to announce version 23.6.0 of magic-folder.

Magic Folder synchronizes local data to and from a Tahoe-LAFS Grid,
keeping data private with the end-to-end encrypted "Capabilities" of
Tahoe-LAFS. One or more magic-folder clients can join the same Folder,
adding and synchronizing data across multiple devices. Written in
Python, Magic Folder supports Linux, MacOS and Windows. Python3 and
PyPy are supported.

By itself, this project requires familiarity with the command-line and
long-running processes. The Gridsync project provides a cross-
platform GUI experience using the localhost HTTP API.

Changes in this release include:

- - security: Bump dependencies, including security-relevant cryptography 
library (#716)

- - feature: Added a description of the datamodel to the documentation (#702)
- - feature: Conflict files now named after the Participant (not Author) (#711)

- - bugfix: "magic-folder status" properly parses scan/poll events (#717)
- - bugfix: Handle updates to conflicted files more robustly (#719)

You may download the release from PyPI:

   https://pypi.org/project/magic-folder/23.6.0/#files

Currently the localhost HTTP API used for integration is not 100%
stable, although we do not expect large changes.

thanks,

meejah
on behalf of all contributors


-BEGIN PGP SIGNATURE-

iQEzBAEBCgAdFiEEnVor1WiOy4id680/wmAoAxKAaacFAmSZNRIACgkQwmAoAxKA
aaeMBggAhijgTKRlYSBbIO+Y/mms4drY2ArEptF+Q5secHo9of68xlL1tQoTGgeF
et/xxgrjmn7WmnQYrC6k0f+xH+6mlW6sNb6wCafUmP/oh3p5bjAGv2tJDmfs81e+
iW7IUWBklx2mLdquwU4nWouJKZjeidqOyBvaBxx30hqOQe3yMwL5mxcliZg9ueZ6
M2HnQZmhA0yKblZrQ8H26dGTSvDLSOOCuHJKab04XYrmOJSJRqYK0DFXogjpNZbB
Ep5wiMpxyEsfPc1bHpxdIJmgJZq1iIgx6dFnHiMNe7yQLykLc9kjPJcxvWRLVsk4
OzN5lHzsiYKsS0g3NVSj+2PKxY3d3w==
=abqD
-END PGP SIGNATURE-
___
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/
Member address: arch...@mail-archive.com