esproc

Split a Huge CSV File into Multiple Smaller CSV Files #eg69

Split a Huge CSV File into Multiple Smaller CSV Files #eg69

Problem description & analysis Below is CSV file sample.csv: v2aowqhugt,q640lwdtat,8cqw2gtm0g,ybdncfeue8,3tzwyiouft,… f0ewv2v00z,x2ck96ngmd,9htr2874n5,fx430s8wqy,tw40yn3t0j,… p2h6fphwco,kldbn6rbzt,8okyllngxz,a8k9slqfms,bqz5fb7cm9,… st63tcbfv8,2n862vqzww,2equ0ydeet,0x5tidunc6,npis28avpj,… bn1u58s39a,mg7064jlrb,edyj3t4s95,zvuf9n29ai,1m0yn8uh0n,… … The file contains a huge volume of data that cannot be wholly loaded into the memory. 100000 rows at most can be loaded at a time into the available memory space. So we need to split the file into multiple smaller CSV files containing 100000 rows each, as shown below: sample1.csv  100000 rows sample2.csv  100000 rows … sample[n].csv  less than or equal to 100000 rows Solution Write the script p1.dfx below in esProc:Explanation A1  Create a cursor for the original CSV file. A2  Loop through…
Read More
Filter a CSV file and re-arrange it by category #eg60

Filter a CSV file and re-arrange it by category #eg60

The CSV file below has 4 columns: idSale (id), Movie (movie name), Genre and Director: Use Java to implement a task: filter the file using Director as the argument, group it by Genre, and print data in the order of genre and then movie names. For example, when argument is set as Christopher Nolan, we have the following result: Here is SPL script: A1: Open the CSV file and filter it by director. A2: Group the file by Genre and loop to compute one group each time. Read How to Call a SPL Script in Java to find how to…
Read More
Replace Duplicate Digits in Every 9-digit Number in a Text File with Non-duplicate Ones #eg52

Replace Duplicate Digits in Every 9-digit Number in a Text File with Non-duplicate Ones #eg52

Problem description & analysis Below is text file txt.txt: 853617639 975336865 The text file contains multiple numeric strings. Each string is 9-digit, and strings are separated by white space. We are trying to process each numeric string and output information according to the following rule: If a digit appears repeatedly, replace it with one within 1-9 that has not been appeared before (find the replacement in natural order). Below is the desired result: 853617249 975316824 Solution Write the following script p1.dfx in esProc: Explanation: A1   Read the text file as a string. A2  Split numeric strings into a sequence using…
Read More
No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.