i have a python program in codebk. it generates me some data. it saves the data in your cloud (i find it in codebk in another folder). is it possible to extractthat data from there to excel, without downloading the file?
1) Confirmation of the workflow (your questions)
Q1: You have a Python syntax running in LSEG CODEBK?
Yes. I run a Python notebook inside LSEG Workspace Codebook (cloud environment).
Q2: That syntax generates data in CODEBK?
Yes. The notebook takes a pasted chat transcript (text), converts it into a tabular dataset (Pandas DataFrame), then appends it into a “master” file (CSV and optionally Excel).
Q3: What do you mean by the data is saved inside CODEBK's environment (folder) – kindly elaborate?
In Codebook, I can create/write files in the project file system (e.g., output/ folder). Those files appear in the Codebook “Files” panel (cloud/project storage). Example test: writing output/write_test.txt succeeds and the file is visible in Codebook.
So the data is stored in the Codebook project storage (cloud), not on my PC’s local disk.
Q4: Are you wanting to extract the data from CODEBK to Excel?
Yes. The goal is to have Excel automatically consume the latest dataset without manually downloading the CSV/Excel file from Codebook each time.
Syntax:
from pathlib import Path
from datetime import datetime
import pandas as pd
OUTPUT_DIR = Path("output")
OUTPUT_DIR.mkdir(exist_ok=True)
CSV_PATH = OUTPUT_DIR / "ChatQuotes_master.csv"
def now_iso():
return datetime.now().astimezone().isoformat(timespec="seconds")
def transcript_to_df(transcript_text: str, source="BBG_CHAT", conversation_id=None, paste_id=None):
capture_ts = now_iso()
rows = []
for i, line in enumerate(transcript_text.splitlines(), start=1):
raw = (line or "").strip()
if not raw:
continue
rows.append({
"capture_ts": capture_ts,
"paste_id": paste_id,
"line_no": i,
"conversation_id": conversation_id,
"raw_line": raw,
"source": source,
# placeholders - parsing of ISIN/bid/ask will be added later
"isin": None, "broker": None, "bid": None, "ask": None
})
return pd.DataFrame(rows)
def append_df_to_csv(path_csv: Path, df: pd.DataFrame):
header = not path_csv.exists()
df.to_csv(path_csv, mode="a", index=False, header=header, encoding="utf-8-sig")
# --- RUN ---
TRANSCRIPT = """(paste chat transcript here)"""
df = transcript_to_df(TRANSCRIPT, conversation_id="BBG_CHAT_BROKERS", paste_id=now_iso())
append_df_to_csv(CSV_PATH, df)
print("Saved to:", CSV_PATH)
This creates/updates: output/ChatQuotes_master.csv in Codebook project storage.