Add a compute column to a csv file #eg40

The csv file below stores assessment parameters:

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 …


This content originally appeared on DEV Community and was authored by Judy

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


This content originally appeared on DEV Community and was authored by Judy


Print Share Comment Cite Upload Translate Updates
APA

Judy | Sciencx (2024-09-12T07:44:31+00:00) Add a compute column to a csv file #eg40. Retrieved from https://www.scien.cx/2024/09/12/add-a-compute-column-to-a-csv-file-eg40/

MLA
" » Add a compute column to a csv file #eg40." Judy | Sciencx - Thursday September 12, 2024, https://www.scien.cx/2024/09/12/add-a-compute-column-to-a-csv-file-eg40/
HARVARD
Judy | Sciencx Thursday September 12, 2024 » Add a compute column to a csv file #eg40., viewed ,<https://www.scien.cx/2024/09/12/add-a-compute-column-to-a-csv-file-eg40/>
VANCOUVER
Judy | Sciencx - » Add a compute column to a csv file #eg40. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/09/12/add-a-compute-column-to-a-csv-file-eg40/
CHICAGO
" » Add a compute column to a csv file #eg40." Judy | Sciencx - Accessed . https://www.scien.cx/2024/09/12/add-a-compute-column-to-a-csv-file-eg40/
IEEE
" » Add a compute column to a csv file #eg40." Judy | Sciencx [Online]. Available: https://www.scien.cx/2024/09/12/add-a-compute-column-to-a-csv-file-eg40/. [Accessed: ]
rf:citation
» Add a compute column to a csv file #eg40 | Judy | Sciencx | https://www.scien.cx/2024/09/12/add-a-compute-column-to-a-csv-file-eg40/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.