I have this python script to update page of confluence with csv file.
```
#!/usr/bin/env python import requests import pandas as pd import json import os # Confluence credentials EMAIL = "user@domain.com" API_TOKEN = os.environ.get('CONFLUENCE_TOKEN') CONFLUENCE_BASE_URL = "https://domain.atlassian.net/wiki/rest/api/" PAGE_ID = "3462135953" PAGE_TITLE = "Legacy Application List" SPACE_KEY = "CP1" # Read CSV file def read_csv(file_path): df = pd.read_csv(file_path) return df.to_html(index=False) # Convert CSV data to HTML # Get current page version def get_page_version(): url = f"{CONFLUENCE_BASE_URL}content/{PAGE_ID}?expand=version" response = requests.get(url, auth=(EMAIL, API_TOKEN)) if response.status_code == 200: return response.json()["version"]["number"] else: print("Error fetching page version:", response.text) return None # Update Confluence page def update_page(csv_html): version = get_page_version() if version is None: return url = f"{CONFLUENCE_BASE_URL}content/{PAGE_ID}" headers = { "Content-Type": "application/json" } data = { "id": PAGE_ID, "type": "page", "title": PAGE_TITLE, # Ensure this is the correct title "space": {"key": SPACE_KEY}, "body": { "storage": { "value": csv_html, "representation": "storage" } }, "version": {"number": version + 1} } response = requests.put(url, headers=headers, auth=(EMAIL, API_TOKEN), data=json.dumps(data)) if response.status_code == 200: print("Page updated successfully!") else: print("Error updating page:", response.text) if __name__ == "__main__": file_path = "test.csv" # Replace with actual CSV file path csv_html = read_csv(file_path) update_page(csv_html)
```
The test.csv content is this,
```
Name,Website
Google,"=HYPERLINK(""https://www.google.com"",""Google"")" OpenAI,"=HYPERLINK(""https://www.openai.com"",""OpenAI"")"
```
Opening the csv and copying the csv manually works fine and the hyperlink is working on Confluence page but using the python script update the page but url doesn't work. Output would be.
```
Name,Website
Google,=HYPERLINK("https://www.google.com","Google")
OpenAI,=HYPERLINK("https://www.openai.com","OpenAI")
```
Please help. Is this possible without excel macro? There's a free macro called "
csv file to table for confluence" not sure how to use it in the pythonscript.
Or use html page instead with lines.