Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.83 KB | None | 0 0
  1. var fs = require('fs');
  2. var parse = require('csv-parse');
  3. var transform = require('stream-transform');
  4.  
  5. var output = [];
  6. var parser = parse({delimiter: ','})
  7. var input = fs.createReadStream('lines.csv');
  8.  
  9. input.pipe(parser).pipe(transform(function(record, callback){
  10. var pos = record[3];
  11. var line = parseInt(record[0]);
  12. if(!pipes[pos]) { console.log('x ' + pos);
  13. pipes[pos] = {};
  14. pipes[pos][1999] = '------------------------------------------------';
  15. pipes[pos][2000] = '------------------- CENTRE ---------------------';
  16. pipes[pos][2001] = '------------------------------------------------';
  17. };
  18. pipes[pos][line-1] = '------------------------------------------------';
  19. if(line == 2000) {
  20. pipes[pos][line] = '---------------- LIGHT / CENTRE ----------------';
  21. } else {
  22. pipes[pos][line] = '-------------------- LIGHT ---------------------';
  23. }
  24. pipes[pos][line+1] = '------------------------------------------------';
  25.  
  26. pipes[pos][line+3] = record[4];
  27. pipes[pos][line+4] = 'Universe: ' + record[1];
  28. pipes[pos][line+5] = 'DMX / Patch: ' + record[2];
  29. pipes[pos][line+6] = 'Offset: ' + record[5] + 'm';
  30.  
  31. callback();
  32.  
  33. }));
  34.  
  35. var pipes = {};
  36.  
  37. setTimeout(function() {
  38.  
  39. for(var myPipe in pipes) {
  40.  
  41. console.log(myPipe);
  42.  
  43. for(var i = 1; i <= 4000; i++) {
  44. var line = pipes[myPipe][i];
  45. if(line) {
  46. fs.appendFileSync(myPipe + '.txt', line + '\n');
  47. } else {
  48. fs.appendFileSync(myPipe + '.txt', '\n');
  49. }
  50. }
  51.  
  52. }
  53.  
  54. }, 5000);
  55.  
  56. /*
  57.  
  58. Line,Universe,Address,Position,Type,X (From SL)
  59. 195,1,108,LX1,Strand Lighting Cantata 18/32,-6.69
  60. 967,1,112,LX1,1200 High Performance Fresnel,-3.83
  61. 1050,1,113,LX1,1200 High Performance Fresnel,-3.52
  62. 1137,1,115,LX1,Source 4 ,-3.2
  63. 1226,1,116,LX1,1200 High Performance Fresnel,-2.87
  64. 1323,1,117,LX1,1200 High Performance Fresnel,-2.51
  65. 1911,1,120,LX1,1200 High Performance Fresnel,-0.33
  66. 2000,1,121,LX1,Source 4 ,0
  67. 2086,1,122,LX1,1200 High Performance Fresnel,0.32
  68. 2691,1,125,LX1,1200 High Performance Fresnel,2.56
  69. 2780,1,126,LX1,1200 High Performance Fresnel,2.89
  70. 2863,1,127,LX1,Source 4 ,3.2
  71. 2950,1,129,LX1,1200 High Performance Fresnel,3.52
  72. 3031,1,130,LX1,1200 High Performance Fresnel,3.82
  73. 3781,1,134,LX1,Strand Lighting Cantata 18/32,6.6
  74. 724,2,428,Line 3,LED Strip HO,-4.73
  75. 1520,2,440,Line 3,LED Strip HO,-1.78
  76. 2451,2,452,Line 3,LED Strip HO,1.67
  77. 3274,2,464,Line 3,LED Strip HO,4.72
  78. 1393,1,379,Line 8,Pendant Bulb,-2.25
  79. 1503,1,380,Line 8,Pendant Bulb,-1.84
  80. 1614,1,381,Line 8,Pendant Bulb,-1.43
  81. 1725,1,382,Line 8,Pendant Bulb,-1.02
  82. 1835,1,383,Line 8,Pendant Bulb,-0.61
  83. 1946,1,384,Line 8,Pendant Bulb,-0.2
  84. 2054,1,385,Line 8,Pendant Bulb,0.2
  85. 2165,1,386,Line 8,Pendant Bulb,0.61
  86. 2275,1,387,Line 8,Pendant Bulb,1.02
  87. 2386,1,388,Line 8,Pendant Bulb,1.43
  88. 2497,1,389,Line 8,Pendant Bulb,1.84
  89. 2607,1,390,Line 8,Pendant Bulb,2.25
  90. 1393,1,367,Line 12,Pendant Bulb,-2.25
  91. 1503,1,368,Line 12,Pendant Bulb,-1.84
  92. 1614,1,369,Line 12,Pendant Bulb,-1.43
  93. 1725,1,370,Line 12,Pendant Bulb,-1.02
  94. 1835,1,371,Line 12,Pendant Bulb,-0.61
  95. 1946,1,372,Line 12,Pendant Bulb,-0.2
  96. 2054,1,373,Line 12,Pendant Bulb,0.2
  97. 2165,1,374,Line 12,Pendant Bulb,0.61
  98. 2275,1,375,Line 12,Pendant Bulb,1.02
  99. 2386,1,376,Line 12,Pendant Bulb,1.43
  100. 2497,1,377,Line 12,Pendant Bulb,1.84
  101. 2607,1,378,Line 12,Pendant Bulb,2.25
  102. 853,3,38,LX2,Mac 550,-4.25
  103. 969,1,144,LX2,1200 High Performance Fresnel,-3.82
  104. 1053,1,145,LX2,1200 High Performance Fresnel,-3.51
  105. 1137,1,147,LX2,Source 4 ,-3.2
  106. 1228,1,148,LX2,1200 High Performance Fresnel,-2.86
  107. 1323,1,149,LX2,1200 High Performance Fresnel,-2.51
  108. 1552,3,26,LX2,Honeycomb Mini,-1.66
  109. 1814,3,65,LX2,Mac 550,-0.69
  110. 1914,1,152,LX2,1200 High Performance Fresnel,-0.32
  111. 2000,1,153,LX2,Source 4 ,0
  112. 2084,1,154,LX2,1200 High Performance Fresnel,0.31
  113. 2183,3,92,LX2,Mac 550,0.68
  114. 2475,3,32,LX2,Honeycomb Mini,1.76
  115. 2688,1,158,LX2,1200 High Performance Fresnel,2.55
  116. 2777,1,159,LX2,1200 High Performance Fresnel,2.88
  117. 2863,1,160,LX2,Source 4 ,3.2
  118. 2947,1,161,LX2,1200 High Performance Fresnel,3.51
  119. 3028,1,162,LX2,1200 High Performance Fresnel,3.81
  120. 3139,3,119,LX2,Mac 550,4.22
  121. 915,2,404,Line 15,LED Strip HO,-4.02
  122. 3082,2,416,Line 15,LED Strip HO,4.01
  123. 1393,1,355,Line 16,Pendant Bulb,-2.25
  124. 1503,1,356,Line 16,Pendant Bulb,-1.84
  125. 1614,1,357,Line 16,Pendant Bulb,-1.43
  126. 1725,1,358,Line 16,Pendant Bulb,-1.02
  127. 1835,1,359,Line 16,Pendant Bulb,-0.61
  128. 1946,1,360,Line 16,Pendant Bulb,-0.2
  129. 2054,1,361,Line 16,Pendant Bulb,0.2
  130. 2165,1,362,Line 16,Pendant Bulb,0.61
  131. 2275,1,363,Line 16,Pendant Bulb,1.02
  132. 2386,1,364,Line 16,Pendant Bulb,1.43
  133. 2497,1,365,Line 16,Pendant Bulb,1.84
  134. 2607,1,366,Line 16,Pendant Bulb,2.25
  135. 1393,1,343,LX3,Pendant Bulb,-2.25
  136. 1503,1,344,LX3,Pendant Bulb,-1.84
  137. 1614,1,345,LX3,Pendant Bulb,-1.43
  138. 1725,1,346,LX3,Pendant Bulb,-1.02
  139. 1835,1,347,LX3,Pendant Bulb,-0.61
  140. 1946,1,348,LX3,Pendant Bulb,-0.2
  141. 2054,1,349,LX3,Pendant Bulb,0.2
  142. 2165,1,350,LX3,Pendant Bulb,0.61
  143. 2275,1,351,LX3,Pendant Bulb,1.02
  144. 2386,1,352,LX3,Pendant Bulb,1.43
  145. 2497,1,353,LX3,Pendant Bulb,1.84
  146. 2607,1,354,LX3,Pendant Bulb,2.25
  147. 516,1,174,LX4,PAR 64,-5.5
  148. 629,1,175,LX4,PAR 64,-5.08
  149. 1018,3,2,LX4,Honeycomb Mini,-3.64
  150. 1137,1,179,LX4,Source 4 ,-3.2
  151. 1557,1,183,LX4,PAR 64,-1.64
  152. 1655,3,8,LX4,Honeycomb Mini,-1.28
  153. 1765,1,184,LX4,PAR 64,-0.87
  154. 1997,1,185,LX4,Source 4 ,-0.01
  155. 2240,1,186,LX4,PAR 64,0.89
  156. 2343,3,14,LX4,Honeycomb Mini,1.27
  157. 2451,1,187,LX4,PAR 64,1.67
  158. 2866,1,190,LX4,Source 4 ,3.21
  159. 2966,3,20,LX4,Honeycomb Mini,3.58
  160. 3371,1,195,LX4,PAR 64,5.08
  161. 3490,1,196,LX4,PAR 64,5.52
  162. 1393,1,331,Line 24,Pendant Bulb,-2.25
  163. 1503,1,332,Line 24,Pendant Bulb,-1.84
  164. 1611,1,333,Line 24,Pendant Bulb,-1.44
  165. 1722,1,334,Line 24,Pendant Bulb,-1.03
  166. 1833,1,335,Line 24,Pendant Bulb,-0.62
  167. 1941,1,336,Line 24,Pendant Bulb,-0.22
  168. 2051,1,337,Line 24,Pendant Bulb,0.19
  169. 2162,1,338,Line 24,Pendant Bulb,0.6
  170. 2270,1,339,Line 24,Pendant Bulb,1
  171. 2380,1,340,Line 24,Pendant Bulb,1.41
  172. 2491,1,341,Line 24,Pendant Bulb,1.82
  173. 2602,1,342,Line 24,Pendant Bulb,2.23
  174. 1350,2,344,Line 25,Legend 230SR Beam,-2.41
  175. 1784,2,359,Line 25,Legend 230SR Beam,-0.8
  176. 2219,2,374,Line 25,Legend 230SR Beam,0.81
  177. 2650,2,389,Line 25,Legend 230SR Beam,2.41
  178. 1727,2,230,Line 28,MAC 301 Wash,-1.01
  179. 1838,2,249,Line 28,MAC 301 Wash,-0.6
  180. 1946,2,268,Line 28,MAC 301 Wash,-0.2
  181. 2054,2,287,Line 28,MAC 301 Wash,0.2
  182. 2162,2,306,Line 28,MAC 301 Wash,0.6
  183. 2273,2,325,Line 28,MAC 301 Wash,1.01
  184. 648,2,148,LX5,Titan 400i,-5.01
  185. 1099,2,152,LX5,Titan 400i,-3.34
  186. 1549,2,156,LX5,Titan 400i,-1.67
  187. 1781,2,176,LX5,Mac 550,-0.81
  188. 2003,1,65,LX5,Strand Lighting Cantata 18/32,0.01
  189. 2103,2,160,LX5,Titan 400i,0.38
  190. 2216,2,203,LX5,Mac 550,0.8
  191. 2451,2,164,LX5,Titan 400i,1.67
  192. 2901,2,168,LX5,Titan 400i,3.34
  193. 3352,2,172,LX5,Titan 400i,5.01
  194. 1137,2,73,Line 32,Legend 230SR Beam,-3.2
  195. 1568,2,88,Line 32,Legend 230SR Beam,-1.6
  196. 2000,2,103,Line 32,Legend 230SR Beam,0
  197. 2432,2,118,Line 32,Legend 230SR Beam,1.6
  198. 2863,2,133,Line 32,Legend 230SR Beam,3.2
  199. 921,2,1,Line 34,LED Strip HO,-4
  200. 1352,2,13,Line 34,LED Strip HO,-2.4
  201. 1784,2,25,Line 34,LED Strip HO,-0.8
  202. 2216,2,37,Line 34,LED Strip HO,0.8
  203. 2648,2,49,Line 34,LED Strip HO,2.4
  204. 3079,2,61,Line 34,LED Strip HO,4
  205.  
  206. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement