Align Merge Two CSV Files according to Namesake Fields #eg64

Problem description & analysis

We have a txt file data1.txt, as shown below:

ID,Name,LastName,Department

12345,John,Samon,Computer Science

14524,David,Souza,Electric and Electronic

And another txt file data2.txt, as shown below:

ID,Q1,Q2,Q3,M…


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

Problem description & analysis

We have a txt file data1.txt, as shown below:

ID,Name,LastName,Department

12345,John,Samon,Computer Science

14524,David,Souza,Electric and Electronic

And another txt file data2.txt, as shown below:

ID,Q1,Q2,Q3,Midterm,Final

12345,100,90,75,89,100

14524,80,70,65,15,90

The two files associate through their IDs in a one-to-one relationship. We are trying to generate a new text file as follows:

ID,Name,avgQ_Average,Midterm,Final,Department

12345,John,88.33,89,100,Computer Science

14524,David,71.67,15,90,Electric and Electronic

Solution

Write the following script p1.dfx in esProc:

Image description
Explanation

A1  Import data1.txt.

A2  Import data2.txt.

A3  Join A1 and A2 through ID field in a one-to-one relationship.

A4  Create the result table sequence according to the specific structure.

A5  Export the result table sequence to mergedFile.txt.

Find how to integrate the script code with a Java program in How to Call an SPL Script in Java.

SPL open source address

Download


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


Print Share Comment Cite Upload Translate Updates
APA

Judy | Sciencx (2024-10-23T05:59:23+00:00) Align Merge Two CSV Files according to Namesake Fields #eg64. Retrieved from https://www.scien.cx/2024/10/23/align-merge-two-csv-files-according-to-namesake-fields-eg64/

MLA
" » Align Merge Two CSV Files according to Namesake Fields #eg64." Judy | Sciencx - Wednesday October 23, 2024, https://www.scien.cx/2024/10/23/align-merge-two-csv-files-according-to-namesake-fields-eg64/
HARVARD
Judy | Sciencx Wednesday October 23, 2024 » Align Merge Two CSV Files according to Namesake Fields #eg64., viewed ,<https://www.scien.cx/2024/10/23/align-merge-two-csv-files-according-to-namesake-fields-eg64/>
VANCOUVER
Judy | Sciencx - » Align Merge Two CSV Files according to Namesake Fields #eg64. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/10/23/align-merge-two-csv-files-according-to-namesake-fields-eg64/
CHICAGO
" » Align Merge Two CSV Files according to Namesake Fields #eg64." Judy | Sciencx - Accessed . https://www.scien.cx/2024/10/23/align-merge-two-csv-files-according-to-namesake-fields-eg64/
IEEE
" » Align Merge Two CSV Files according to Namesake Fields #eg64." Judy | Sciencx [Online]. Available: https://www.scien.cx/2024/10/23/align-merge-two-csv-files-according-to-namesake-fields-eg64/. [Accessed: ]
rf:citation
» Align Merge Two CSV Files according to Namesake Fields #eg64 | Judy | Sciencx | https://www.scien.cx/2024/10/23/align-merge-two-csv-files-according-to-namesake-fields-eg64/ |

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.