Jump to content

Excel output in 8.0


---
 Share

Recommended Posts

I'm setting up a program to send the report to Excel. The only thing that shows up in the spreadsheet is the header. No data. What am I missing?

Link to comment
Share on other sites

Upon closer review, the header isn't right on top of it. Tried using the spreadsheet from 7.8 and still have the same problem.

Link to comment
Share on other sites

Typically, for me, I found I was not generating a Characteristic and or Feature text files.

The excel templates populate the final excel file based on those two files.

  • Like! 1
Link to comment
Share on other sites

Please sign in to view this quote.

The problem I have right now is that some plans on the offline system are not generating the txt files even with them being enabled in results to file menu. The same plan on the live machine - generates files with no issues. One of the many quirks of 8.0 I guess. 

Link to comment
Share on other sites

Please sign in to view this quote.

I have this issue on one live CMM where the Characteristic file will pop up a dialog box telling me it cant create the file.

I then have to stop the program and restart to cycle thru the data again, then it seems to work. I a m pretty sure I have a post in this forum about it.

I have not been able to solve the problem.

  • Like! 1
Link to comment
Share on other sites

Zeiss should steal this and make it the default!  "I just want an excel with all the data i just captured"

 

super cool script!

  • Like! 1
Link to comment
Share on other sites

  • 2 weeks later...

Thanks Jeff. We're just starting to get into ChatGPT so I'll have to give it a try. How did you get it to watch a specific folder?

  • Like! 1
Link to comment
Share on other sites

"""
Calypso _chr.txt Auto Parser → Excel + CSV
Proof-of-Concept version
-------------------------------------------------
Watches a folder for new Calypso _chr.txt files,
extracts characteristic data, and exports to:
  - Excel (.xlsx) for FAI report
  - CSV (.csv) for SPC software

Dependencies:
  pip install watchdog pandas openpyxl
"""

import os
import time
import pandas as pd
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
from datetime import datetime


# --- CONFIG ---
WATCH_FOLDER = r"C:\CalypsoExports"        # Folder containing _chr.txt files
OUTPUT_FOLDER = r"C:\CalypsoExports\Out"   # Where Excel and CSV will be saved
FILE_PATTERN = "_chr.txt"                  # File suffix to watch
POLL_DELAY = 5                             # Seconds between folder checks
# --------------


def parse_chr_file(file_path: str) -> pd.DataFrame:
    """
    Parse a Calypso characteristic table export (_chr.txt).
    Assumes tab- or space-separated text with headers.
    """
    print(f"Parsing: {file_path}")
    try:
        # Try tab first, then whitespace if needed
        df = pd.read_csv(file_path, sep="\t", engine="python")
        if len(df.columns) <= 1:
            df = pd.read_csv(file_path, delim_whitespace=True, engine="python")
    except Exception as e:
        print(f"Failed to parse {file_path}: {e}")
        return pd.DataFrame()

    # Normalize headers
    df.columns = [c.strip() for c in df.columns]
    df = df.rename(columns={
        "Name": "Characteristic",
        "Nominal": "Nominal",
        "Actual": "Measured",
        "Dev": "Deviation",
        "UpTol": "Upper Tol",
        "LoTol": "Lower Tol"
    })

    # Add result status
    if "Measured" in df.columns and "Nominal" in df.columns:
        df["Status"] = (df["Deviation"].abs() <= (df["Upper Tol"].abs())).map(
            {True: "PASS", False: "FAIL"}
        )

    return df


def export_reports(df: pd.DataFrame, source_file: str):
    """
    Export the parsed dataframe to Excel and CSV.
    """
    if df.empty:
        print("No data to export.")
        return

    base_name = os.path.splitext(os.path.basename(source_file))[0]
    timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
    excel_path = os.path.join(OUTPUT_FOLDER, f"{base_name}_{timestamp}.xlsx")
    csv_path   = os.path.join(OUTPUT_FOLDER, f"{base_name}_{timestamp}.csv")

    os.makedirs(OUTPUT_FOLDER, exist_ok=True)
    df.to_excel(excel_path, index=False)
    df.to_csv(csv_path, index=False)

    print(f" Exported Excel: {excel_path}")
    print(f" Exported CSV:   {csv_path}")


class CHRHandler(FileSystemEventHandler):
    """Watchdog event handler for new _chr.txt files"""

    def on_created(self, event):
        if event.is_directory:
            return
        if event.src_path.lower().endswith(FILE_PATTERN):
            time.sleep(1)  # allow file to finish writing
            df = parse_chr_file(event.src_path)
            export_reports(df, event.src_path)


def watch_folder():
    """Continuously watch folder for new files"""
    print(f"Watching folder: {WATCH_FOLDER}")
    event_handler = CHRHandler()
    observer = Observer()
    observer.schedule(event_handler, WATCH_FOLDER, recursive=False)
    observer.start()

    try:
        while True:
            time.sleep(POLL_DELAY)
    except KeyboardInterrupt:
        observer.stop()
    observer.join()


if __name__ == "__main__":
    watch_folder()

💡 How It Works

  1. Start the script — it begins monitoring C:\CalypsoExports

  2. Drop or save a new file ending with _chr.txt

  3. Script:

    • Parses the file automatically

    • Creates Excel and CSV outputs in C:\CalypsoExports\Out

    • Adds timestamps to the filenames

  4. Each file is processed once upon creation


🔧 Next Steps (after proof of concept)

Once you confirm the basic flow works, we can:

  • Map to your actual Calypso column names

  • Match your company’s Excel FAI layout (with formatting and headers)

  • Build the SPC CSV exactly as your local software requires

  • Add archiving, error logs, and GUI controls



    The sky is the limit for you!

  • Like! 2
Link to comment
Share on other sites

That's what the chat bot is for, but I will say that is beneficial to you to use the tool to help you learn how to do this, instead of just having it feed the information to you. 

  • Like! 1
Link to comment
Share on other sites

Hi

Please sign in to view this username.

 Exactly what

Please sign in to view this username.

 said.
 

Large Language Models (AI) like ChatGPT can do the work for you.


In this case, it made me aware that there is a simple, publicly available add-on for python scripts called watchdog that watches the folder for you. A script using it can be finely-tuned to act on specific triggers, like watching for any file that gets dropped into a folder or even checking for specific content inside that file before proceeding. While watchdog is perfect for these file-based events, other simple automation tools can handle time-based triggers, like running a task once per day.

The solution I implemented was a combined effort between ChatGPT and Google's Gemini. When one AI got stuck or seemed ineffective, I would make the conversation available via link to the other AI, and that often helped me navigate roadblocks in development.

I also educated myself during this process on parts of the code that were critical to functionality. In essence, while the AI is the workhorse here, I'm learning about coding at the same time.

People don't have to feel intimidated by solutions like this, and they don't have to be experts. Being successful at AI-generated solutions requires one primary asset: Curiosity

  • Like! 1
Link to comment
Share on other sites

I hear ya. One thing though that makes it a lot tougher for me personally is that I hadn't even seen a ChatGPT screen before 2 or 3 weeks ago and a lot of stuff like bots, code interpreter, python scripting, Watchdog, etc. is stuff I've never even heard of before. So it's not just learning how to interact in ChatGPT, it's trying to learn all the other stuff that goes along with it at the same time. In a way it's kind of overwhelming, especially for an old geezer that my wife calls dain-bramaged.

  • Like! 2
Link to comment
Share on other sites

Please sign in to view this username.

 Totally understandable.

I tip my hat to you for hopping on the forums here and looking for a solution.  You're learning, and be encouraged by how far you've come.

The bottom line is that the output to Excel option from Calypso should be more functional and user friendly than it is.

The current scripting that drives Calypso's Excel output was literally made decades ago, and it was never modernized like other parts of Calypso have been.

Were you able to make any progress with the "only headers are populating" problem?

  • Like! 2
Link to comment
Share on other sites

Thanks for the compliment. Yes I did. Fortunately I didn't have to resort to python scripting. I agree with you. Zeiss not only needs to do a better job of keeping up with Excel changes, but they also need to do a better job of explaining what button does what. A pet peeve of mine is that Zeiss runs a lot of their documentation through a language translator and then doesn't have it proof-read by someone who knows English really well to see if it makes sense, because some of it doesn't.

At any rate, thanks again. The help is appreciated. I'll probably be back with more questions on other subjects.

  • Like! 1
Link to comment
Share on other sites

Jack, the Germanglish pet peeve is shared by many.  It makes it difficult to learn the software from the vendor's documentation.

I guess it helps me empathize with how complicated the English language is and how frustrating it must be to have to learn it.

Not even joking... universal translators will be a reality in the next decade or two, both for audio and written communication.  There are wearable prototypes in development that translate the conversation of someone in earshot to the wearer of the listening device.

Star Trek but for real.  Next, I hope they work on the food replicators.

Link to comment
Share on other sites

Please sign in to view this quote.

Just a side note from someone who isn't native speaking english, English is actually an easy language to learn. It doesnt have many "special rules".

Compare it to lets say swedish, that is many times harder. We have a lot of special rules how to bend words. I'm amazed with non natives that speak and write correctly.

English/Swedish:

A train / Ett tåg

A bike / En cykel

 

Bikes / Cyklar

Mopeds / Mopeder

Appels / Äpplen

Trains / Flera tåg

 

Then we have space or no space in words? English, always (almost) space. Swedish, well here things can go VERY wrong. Words completely change the their meaning.

Smoke free / Rök fritt/Rökfritt.

Rökfritt = Do not smoke!

Rök fritt = Smoke as much as you like.

 

 

And this I could continue for the rest of the day....

Edited
  • Like! 2
  • Awesome! 1
Link to comment
Share on other sites

Airpods can do live translation /today/(!)

 

Be careful about asking chatgpt to do math.  Boy its good at programming but can lose the plot very easily dealing with actual numbers.   I trust the above code more than i trust its answer to 2+2

  • Like! 1
Link to comment
Share on other sites

"Germanglish"  Ha!!! Love it! Funny.

I'm not surprised to hear (no pun intended) Airpods do translations. Logical progression of technology. I am surprised though that it wasn't more publicized when it was released. I'm sure all the Star Trek fans would want one. Apple is missing a big opportunity.

  • Like! 1
Link to comment
Share on other sites

Curious if anyone else here uses the DataBridgeXL macro to transfer data from Calypso to Excel?

I learned about this tool a few years back during a Calypso continuing e-learning class put on by Zeiss and I could swear it was a downloadable file for a while through the portal but I can find no trace of it on the portal or in these new forums. Maybe it was phased out with the push on PiWeb and/or maybe it doesn't work on the newest versions of Calypso but it still works fine on version Calypso 2021 Service Pack 1, version 7.2.04 that we are still running. I don't think I am allowed to share it here, my class materials say not to at the bottom of each page so this tool may be proprietary? Maybe someone from Zeiss could validate its existence or they can give more info on it officially.

Anyway, I found it extremely useful especially for taking the data in Excel form and being able to drop it into our custom Excel inspection sheets. When I first started my role I was expected to transfer the information by hand which felt incredibly unnecessary to me but the persons that held my position previously never dug deep into Calypso to make their job easier. It takes some setting up initially but then it is simply a click and you get your data and you can then move it around as you see fit.

Edited
  • Like! 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...