Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. const result = [
  2. {
  3. Id: "1",
  4. Char1: "a; b; c",
  5. Char2: "d; e; f"
  6. }
  7. ];
  8.  
  9. Id,Char1,Char2
  10. 1,a,d
  11. 1,b,e
  12. 1,c,f
  13.  
  14. Id,Char1,Char2
  15. 1,a,d
  16. 1,a,e
  17. 1,a,f
  18. 1,b,d
  19. 1,b,e
  20. 1,c,f
  21. 1,c,d
  22. 1,c,e
  23. 1,c,f
  24.  
  25. result
  26. .reduce((acc, {
  27. Id,
  28. Char1,
  29. Char2
  30. }) => {
  31. const a = Char1.split(";");
  32. const c = Char2.split(";");
  33. a.forEach((item, index) => {
  34. acc.push({
  35. Id: Id,
  36. Char1: item,
  37. Char2: c[index]
  38. });
  39. });
  40. return acc;
  41. }, [])
  42. .forEach(item => {
  43. lines.push(rowData.map(key => item[key]).join(","));
  44. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement