DEV Community

Judy
Judy

Posted on

2 1 1 1 1

Add a compute column to a csv file #eg40

The csv file below stores assessment parameters:

Image description
Use Java to do this: Compute Final Grade (the 4th column) value according to the existing 3 columns using the formula Lab Exercise * 30% + Long Quiz * 30% + Alternative Assessment * 40%, and write the result to a new csv file.

Image description
Write the following SPL code:

Image description
T()function parses a csv file or generates a new one. derive() function adds a compute column.

Read How to [Call a SPL Script in Java](T()function parses a csv file or generates a new one. derive() function adds a compute column.

Read How to Call a SPL Script in Java to find how to integrate SPL into a Java application.) to find how to integrate SPL into a Java application.

This is one of the problems on StackOverflow. You can click on it to see that the conventional solution is quite complicated, but the SPL approach is really simple and efficient.

SPL open source address

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more