• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Java Code to split text file based on count and customer ID

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please share java code for below requirement as i am new to Java. I am an SAP PI/PO Developer.
Business Requirement:
We have a large Sale Order text file (around 1 million records) and it should be split into multiple files. Each split file will have approximately 100k records and all orders of same customer. Each split file will have multiple customers order data since few customers have few orders data. So during split we should make sure orders of same customer should not be split and should be in same file.

Below is sample Input data: We have 2 customers order data in below sample data. One customer "1-RK98LJ" has 3 orders and another customer "E1-3JKQDD1" has 2 orders. CUSTOMERID|INTERACTIONCONTACTORIGIN|ORDERNUMBER|INTERACTIONTYPE (Header Record)
1-RK98LJ|SIEBEL_ID|24678|SHOP_CHECKOUT_SUCCES
1-RK98LJ|SIEBEL_ID|87697|SALES_ORDER
1-RK98LJ|SIEBEL_ID|88543|SALES_ORDER
E1-3JKQDD1|SIEBEL_ID|98654|SALES_ORDER
E1-3JKQDD1|SIEBEL_ID|14567|SALES_ORDER
E2-3JKPPP1|SIEBEL_ID|14567|SHOP_CHECKOUT_SUCCES
E3-3JKAQS1|SIEBEL_ID|14567|SALES_ORDER

for example,if Split file will have approximately 2 records and and all orders of same customer then below is expected output.

output for File1: Although split size is 2, below Split file has 3 orders (excluding header record) since 3 orders of same customer.
CUSTOMERID|INTERACTIONCONTACTORIGIN|ORDERNUMBER|INTERACTIONTYPE
1-RK98LJ|SIEBEL_ID|24678|SHOP_CHECKOUT_SUCCES
1-RK98LJ|SIEBEL_ID|87697|SALES_ORDER
1-RK98LJ|SIEBEL_ID|88543|SALES_ORDER

output for File2: Below Split file has 2 orders(excluding header record).
CUSTOMERID|INTERACTIONCONTACTORIGIN|ORDERNUMBER|INTERACTIONTYPE
E1-3JKQDD1|SIEBEL_ID|98654|SALES_ORDER
E1-3JKQDD1|SIEBEL_ID|14567|SALES_ORDER

output for File3: Below Split file has 2 orders(excluding header record). CUSTOMERID|INTERACTIONCONTACTORIGIN|ORDERNUMBER|INTERACTIONTYPE
E2-3JKPPP1|SIEBEL_ID|14567|SHOP_CHECKOUT_SUCCES
E3-3JKAQS1|SIEBEL_ID|14567|SALES_ORDER

Could you please let me know if you need any more information.
 
Saloon Keeper
Posts: 5776
146
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

We won't write the code for you, but we will help you write it yourself. So: What do you have so far, and where are you stuck making progress?
 
Don't destroy the earth! That's where I keep all my stuff! Including this tiny ad:
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!