Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import from planner #92

Open
DamienKoala opened this issue Oct 30, 2024 · 0 comments
Open

import from planner #92

DamienKoala opened this issue Oct 30, 2024 · 0 comments

Comments

@DamienKoala
Copy link

Hello,

I really appreciate your work, and his simplicity ! I'm trying to interact from nullboard to pythonscript (href = action.py).

I'm not experienced in js/css. How should i add a class in note (text, raw, min and... "class" ?) in order to custumize them ? Something like that :

.board .note.class {
		background: #75B843;
		margin-top: 5px;
		box-shadow: 0 1px 2px #bbb, 0 0 1px #ddd;
		position: relative;
	}

I propose this if it could help someone to import Planner kanban with Python :

import pandas as pd
import json

compartiments = {}

for index, row in planner.iterrows():
    nom_compartiment = row["Nom du compartiment"]
    nom_tache = row["Nom de tâche"]
    description = row["Description"] 
    elements_liste_controle = row["Éléments de la liste de contrôle"]

    if nom_compartiment not in compartiments:
        compartiments[nom_compartiment] = {"title": nom_compartiment, "notes": []}

    # Name of task only
    # Add task raw = True
    compartiments[nom_compartiment]["notes"].append({
        "text": nom_tache,
        "raw": True,
        "min": False
    })
    # Vérifier si la description est NaN
    if pd.notna(description):
      if description.startswith("_x000d_\n"):  # Vérifier si la description commence par _x000d_\n
        description = description.replace("_x000d_\n", "")

      else:
        description = description.replace("_x000d_\n", "\n")  # Remplacer ailleurs dans la chaîne
        description = description.replace("_x000d_", "")  # Remplacer ailleurs dans la chaîne

      if len(description) > 0:
        compartiments[nom_compartiment]["notes"].append({
          "text": description,
          "raw": False,
          "min": True
        })

    # Add Elements control under the task
    # Vérifier si Elements de contrôles est NaN
    if pd.notna(elements_liste_controle):
        elements_liste_controle = elements_liste_controle.replace("_x000d_\n", "\n") # Pour les premières lignes
        elements_liste_controle = elements_liste_controle.replace("_x000d_", "")
        items_controle = elements_liste_controle.split(";")  # Découper la chaîne en items

        # Ajouter chaque item séparément au JSON
        for item in items_controle:
          if len(item) > 0:
            compartiments[nom_compartiment]["notes"].append({
              "text": item.strip(),  # Supprimer les espaces en début et fin d'item
              "raw": False,
              "min": False
        })

GENIAL_json = {
 'format': 20190412,
 'id': 1,
 'revision': 1,
 'title': 'Titre',
 'lists': [], 
}

GENIAL_json["lists"] = list(compartiments.values())

 open('GenIA-L.nbx', 'w') as f:
  json.dump(GENIAL_json, f, indent=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant