我的JavaScript假设CSV是二维的,它只适用于一维的CSV

时间:2021-09-03 12:33:02

How do I parse this CSV with JavaScript?

如何用JavaScript解析CSV ?

1363085391,42.890000000000,5.4322000000001363088879,47.570000000000,4.9818000000001363120475,56.560000000000,1.7680000000001363132522,53.000000000000,1.0000000000001363214378,48.630000000000,4.000000000000[...]

It shows the bitcoin price and trade volume history for the Canadian dollar. However, the list is too massive; it shows every trade ever done. So I'm trying to reduce it from hundreds of data points a day to one per week. Basically "monotizing" the data points into time span intervals by adding up the volume and averaging the price. This way, with simpler data, the line in my line chart is expected to look a whole lot better.

它显示了加拿大元的比特币价格和交易量历史。然而,这份名单太过庞大;它显示了每一笔交易。所以我试着把它从每天几百个数据点减少到每周一个。基本上就是把数据点“集中”成时间间隔,通过增加体积和平均价格。通过这种方式,使用更简单的数据,我的折线图中的线看起来会好得多。

Unfortunately the script won't work; it assumes the CSV is a two-dimensional array, but in reality I think it's only one-dimensional? How do I change it so it parses the CSV properly?

不幸的是,脚本无法工作;它假设CSV是一个二维数组,但实际上我认为它只是一维的?如何修改它,使它能正确解析CSV ?

function simplifyData(data_set) {  interval_length = 3600; // hourly intervals  last_price = 0;  idx = 0;  while (idx < data_set.length) {    // reset value for this interval    volume = 0;    price_sum = 0;    count = 0;    timestamp = data_set[idx]['timestamp'] + interval_length;    // get sums for this interval    while (data_set[idx]['timetamp'] < timestamp) {      volume += data_set[idx]['volume'];      price_sum += data_set[idx]['price'];      count++;      idx++;      if (idx >= data_set.length)        break;    }    // get average price    price = count > 0 ? price_sum / count : last_price;    last_price = price;    // add new row to monotized data array    monotized_data.append([      timestamp: timestamp,      volume: volume,      price: price    ]);  }}// Format: time (UNIX timestamp), price, amount traded// http://api.bitcoincharts.com/v1/csv/localbtcCAD.csv.gzvar complexCadCsv = "1363085391,42.890000000000,5.4322000000001363088879,47.570000000000,4.9818000000001363120475,56.560000000000,1.7680000000001363132522,53.000000000000,1.0000000000001363214378,48.630000000000,4.0000000000001363217281,48.770000000000,2.0002000000001363223157,48.860000000000,2.0465000000001363232051,49.110000000000,4.2355000000001363272551,54.250000000000,1.0000000000001363283662,49.780000000000,5.9256000000001363293072,55.500000000000,1.0270000000001363321440,56.000000000000,5.3571000000001363346950,55.220000000000,7.0169000000001363379555,55.600000000000,4.9459000000001363379607,55.740000000000,1.0000000000001363381362,49.220000000000,0.1016000000001363382662,49.220000000000,4.8961000000001363391161,55.380000000000,2.0000000000001363401704,56.060000000000,1.0000000000001363467393,56.000000000000,0.8929000000001363496639,56.700000000000,1.5001000000001363524530,56.930000000000,6.0001000000001363527377,56.900000000000,6.4979000000001363542700,56.000000000000,2.1429000000001363547113,55.000000000000,3.0000000000001363564084,57.040000000000,2.1564000000001363638453,57.880000000000,0.3317000000001363729323,70.000000000000,0.8571000000001363740718,73.070000000000,0.1368000000001363795449,63.450000000000,1.0000000000001363795494,63.860000000000,1.0001000000001363795603,63.430000000000,0.1577000000001363798700,68.390000000000,1.4622000000001363800835,68.180000000000,1.9913000000001363803497,67.940000000000,1.0146000000001363803790,68.160000000000,1.0271000000001363814790,69.580000000000,1.0500000000001363814810,68.270000000000,0.9294000000001363825583,68.250000000000,5.2306000000001363829358,78.000000000000,1.0500000000001363836583,83.300000000000,2.9998000000001363837642,84.000000000000,2.0000000000001363895966,75.410000000000,0.6630000000001363944788,75.000000000000,4.0000000000001363984884,90.000000000000,1.1111000000001363987472,90.000000000000,1.1111000000001363988438,89.350000000000,0.0740000000001363989586,85.090000000000,1.9999000000001364000191,88.000000000000,1.0000000000001364002717,85.230000000000,1.4901000000001364010104,70.730000000000,1.0000000000001364013267,86.000000000000,1.1628000000001364073182,78.000000000000,3.9000000000001364089933,80.000000000000,3.0250000000001364249509,74.360000000000,1.4856000000001364262262,89.550000000000,1.1167000000001364265293,90.040000000000,1.0550000000001364310351,92.450000000000,1.0817000000001364334487,81.210000000000,1.9948000000001364355951,94.630000000000,1.4200000000001364357864,95.380000000000,1.0484000000001364358542,94.800000000000,1.0549000000001364364067,82.820000000000,13.2198000000001364395451,99.100000000000,0.1009000000001364400184,102.700000000000,1.0000000000001364401183,100.570000000000,1.0938000000001364403945,101.420000000000,1.0000000000001364411110,101.720000000000,0.4988000000001364436263,106.740000000000,1.7999000000001364436873,94.960000000000,1.0000000000001364437451,94.520000000000,0.9999000000001364440483,104.190000000000,0.4999000000001364489123,109.760000000000,1.0478000000001364490688,109.730000000000,1.0000000000001364494732,100.230000000000,1.0000000000001364498537,95.620000000000,1.9500000000001364502332,95.780000000000,1.2007000000001364505883,99.490000000000,0.2513000000001364513250,103.900000000000,0.5171000000001364516343,83.470000000000,1.0183000000001364573738,97.140000000000,0.2574000000001364580938,95.700000000000,1.0000000000001364598407,102.000000000000,1.0000000000001364600233,102.000000000000,1.0000000000001364601641,102.000000000000,1.0100000000001364605133,105.000000000000,1.0000000000001364709921,99.880000000000,1.0000000000001364712798,99.990000000000,1.0001000000001364748894,101.470000000000,1.0000000000001364755340,100.590000000000,3.0000000000001364792969,106.000000000000,1.0000000000001364799933,102.400000000000,1.0000000000001364800923,101.560000000000,1.0000000000001364828813,112.000000000000,2.0000000000001364832014,115.000000000000,5.0000000000001364832308,115.000000000000,3.0000000000001364834249,112.720000000000,5.8550000000001364838578,115.240000000000,5.7274000000001364841672,104.360000000000,12.4572000000001364923361,120.900000000000,2.9999000000001364936087,120.710000000000,4.9706000000001364948998,124.810000000000,4.9998000000001364959661,127.170000000000,0.9950000000001364965648,121.770000000000,1.0000000000001364973827,136.060000000000,1.0000000000001364974001,147.890000000000,4.0001000000001364998794,140.320000000000,3.5632000000001365026364,123.790000000000,1.0154000000001365027711,127.780000000000,6.2609000000001365046987,138.360000000000,4.0000000000001365057275,138.500000000000,5.4999000000001365065898,157.040000000000,1.9994000000001365090058,145.220000000000,5.5090000000001365104881,164.890000000000,5.4582000000001365105565,139.710000000000,1.2500000000001365138055,145.850000000000,1.8499000000001365167322,166.250000000000,0.6015000000001365173858,146.080000000000,1.9999000000001365174283,148.260000000000,0.1349000000001365183486,149.890000000000,3.0001000000001365184905,161.740000000000,2.0001000000001365205476,152.790000000000,1.0000000000001365210365,175.000000000000,1.0000000000001365219395,150.960000000000,0.9997000000001365220927,150.910000000000,1.0000000000001365268452,153.390000000000,0.6520000000001365272285,170.000000000000,1.0000000000001365274795,170.000000000000,1.0000000000001365278764,170.000000000000,1.0000000000001365278930,154.030000000000,0.5194000000001365280374,170.000000000000,1.0000000000001365281909,154.560000000000,0.6500000000001365283450,170.000000000000,1.0000000000001365287835,170.000000000000,1.5412000000001365303267,153.940000000000,3.5001000000001365312742,155.620000000000,0.1285000000001365325139,161.570000000000,3.0000000000001365349680,169.230000000000,2.0000000000001365354798,138.110000000000,1.0100000000001365356226,180.190000000000,1.6649000000001365362290,174.010000000000,0.2873000000001365377549,173.640000000000,2.0000000000001365379774,175.010000000000,1.0000000000001365384562,179.980000000000,2.2225000000001365396478,183.290000000000,2.0000000000001365434139,203.850000000000,0.0981000000001365434614,208.360000000000,1.0000000000001365437520,197.620000000000,2.0000000000001365440837,195.520000000000,4.0000000000001365449254,197.610000000000,4.0000000000001365467994,202.160000000000,2.9905000000001365469985,202.160000000000,1.5002000000001365478982,206.360000000000,0.9977000000001365479416,206.220000000000,1.0000000000001365479554,203.290000000000,1.0000000000001365486039,207.860000000000,0.4653000000001365500973,219.210000000000,2.2809000000001365518766,228.930000000000,1.9701000000001365518846,225.910000000000,0.9960000000001365520063,229.770000000000,0.7473000000001365521859,235.270000000000,3.0000000000001365521926,235.270000000000,0.8501000000001365524515,240.510000000000,3.3262000000001365524659,235.400000000000,0.9991000000001365526701,238.440000000000,1.0000000000001365527072,242.330000000000,2.0000000000001365527199,240.510000000000,1.3097000000001365529148,251.570000000000,1.0000000000001365537800,265.560000000000,1.0000000000001365542522,305.000000000000,1.5082000000001365542586,305.000000000000,1.8934000000001365551390,335.650000000000,0.7150000000001365554253,265.540000000000,1.0000000000001365558982,284.240000000000,1.0000000000001365563330,306.440000000000,0.3263000000001365566909,310.950000000000,0.0643000000001365578721,338.530000000000,1.1816000000001365606252,273.660000000000,1.0000000000001365610294,281.800000000000,2.1292000000001365612809,265.810000000000,2.0000000000001365618499,262.140000000000,1.0000000000001365628947,250.000000000000,1.9440000000001365629291,253.640000000000,1.1828000000001365642148,151.740000000000,2.0000000000001365642413,141.270000000000,2.0000000000001365678778,188.540000000000,3.9931000000001365703940,148.580000000000,4.4554000000001365716351,151.650000000000,0.6800000000001365717197,136.400000000000,1.0000000000001365717771,122.450000000000,1.9518000000001365724442,124.000000000000,2.0000000000001365773281,117.460000000000,1.2515000000001365773887,121.000000000000,1.9918000000001365776714,122.360000000000,2.2311000000001365795875,114.590000000000,1.0000000000001365796323,115.000000000000,2.0000000000001365798963,106.190000000000,2.0000000000001365802678,106.180000000000,1.0000000000001365804038,111.410000000000,1.7900000000001365810280,109.980000000000,1.5000000000001365811712,115.000000000000,2.0000000000001365813104,109.970000000000,1.0000000000001365816966,165.200000000000,3.0266000000001365819572,150.000000000000,1.0667000000001365820699,128.730000000000,1.6499000000001365823425,124.060000000000,3.2244000000001365826775,150.000000000000,1.0667000000001365877655,150.000000000000,2.0000000000001365878739,159.330000000000,2.0085000000001365884739,150.000000000000,4.0000000000001365888397,150.000000000000,3.0000000000001365956959,150.000000000000,5.3300000000001365961896,140.000000000000,0.5357000000001365979939,142.140000000000,1.0000000000001365991144,128.990000000000,2.0000000000001365993080,150.000000000000,1.3333000000001366014910,135.000000000000,4.4444000000001366022593,149.640000000000,0.4678000000001366044482,123.500000000000,3.0291000000001366045307,119.750000000000,1.0021000000001366048928,119.750000000000,0.6681000000001366055142,109.990000000000,0.1818000000001366062216,109.480000000000,1.0800000000001366065512,100.000000000000,0.1810000000001366085870,88.150000000000,1.0000000000001366085948,91.540000000000,0.4369000000001366097421,74.700000000000,10.4953000000001366129928,96.000000000000,2.0833000000001366130124,99.720000000000,4.0000000000001366133447,99.890000000000,1.0000000000001366135520,103.730000000000,1.1000000000001366138028,95.390000000000,1.1000000000001366144237,69.480000000000,1.5113000000001366145377,75.000000000000,2.5867000000001366155682,89.800000000000,2.0000000000001366158005,88.800000000000,1.0000000000001366158456,89.800000000000,1.9933000000001366164776,94.000000000000,2.0000000000001366173698,102.640000000000,1.9974000000001366198863,103.450000000000,1.9914000000001366211035,102.450000000000,2.1962000000001366218782,94.000000000000,3.0000000000001366225431,94.000000000000,2.0426000000001366233216,214.470000000000,1.0000000000001366318951,108.730000000000,0.9197000000001366387777,129.690000000000,1.9822000000001366394307,135.420000000000,0.1846000000001366413885,134.140000000000,0.2982000000001366551162,136.710000000000,0.1296000000001366553999,140.700000000000,2.4875000000001366620334,137.830000000000,0.4208000000001366671189,107.380000000000,1.5000000000001366684569,141.740000000000,1.0000000000001366686872,142.090000000000,1.0556000000001366687106,142.130000000000,1.7590000000001366746322,148.230000000000,3.3731000000001366825778,159.250000000000,0.1256000000001366903154,166.040000000000,1.5400000000001366903247,168.230000000000,0.1189000000001366906417,165.440000000000,1.5883000000001366906495,166.300000000000,1.0000000000001366912064,164.670000000000,2.1300000000001366914573,164.820000000000,0.1820000000001366978559,143.290000000000,1.3958000000001367001597,144.390000000000,1.0389000000001367002599,165.650000000000,1.0000000000001367024672,142.890000000000,0.8100000000001367027540,144.780000000000,1.4505000000001367027692,146.310000000000,2.0000000000001367029695,143.800000000000,0.7500000000001367034952,143.800000000000,3.1295000000001367043181,143.710000000000,2.2615000000001367085501,141.190000000000,1.4166000000001367100612,155.680000000000,1.2819000000001367182014,170.140000000000,1.0000000000001367182173,169.720000000000,1.1195000000001367186205,170.710000000000,1.0000000000001367275779,153.550000000000,1.4653000000001367289143,198.350000000000,6.0499000000001367323428,197.180000000000,7.0000000000001367331486,155.660000000000,1.6060000000001367348392,189.950000000000,5.2646000000001367351603,146.060000000000,2.9988000000001367356384,188.010000000000,7.1380000000001367364586,167.170000000000,0.1795000000001367364740,191.010000000000,7.8530000000001367378952,165.000000000000,1.8182000000001367423338,142.430000000000,3.9319000000001367446179,133.240000000000,2.2516000000001367457397,131.820000000000,1.2734000000001367474137,129.410000000000,0.3900000000001367506472,125.970000000000,0.0794000000001367517588,112.580000000000,4.4414000000001367534445,116.880000000000,0.1711000000001367562381,108.910000000000,0.5509000000001367591999,106.120000000000,0.4712000000001367595257,104.460000000000,0.4786000000001367599098,144.030000000000,1.0415000000001367604271,99.230000000000,2.9627000000001367625410,103.810000000000,2.022900000000"var finalOutput = simplifyData(complexCadCsv);$(".new_csv").append(finalOutput);
<!--<script src="https://rawgit.com/evanplaice/jquery-csv/master/src/jquery.csv.min.js"></script>--><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><h1>New simplified CSV</h1><div class="new_csv"></div>

1 个解决方案

#1


2  

data_set is a string, but simplifyData() is access it as if it's an array of objects. You need to convert it first.

data_set是一个字符串,但是simplifyData()访问它就好像它是一个对象数组。你需要先转换它。

data_set = data_set.split('\n').map(line => {    var linearray = line.split(',');    return {        timestamp: parseInt(linearray[0], 10),        price: parseFloat(linearray[1]),        volume: parseFloat(linearray[2])    };});

And in your call to monotized_data.append, you have square brackets when you should have curly braces, and you should be calling push()

在对monotized_data的调用中。追加,方括号应该是花括号,应该是push()

    monotized_data.push({      timestamp: timestamp,      volume: volume,      price: price    });

function simplifyData(data_set) {  interval_length = 3600; // hourly intervals  last_price = 0;  idx = 0;    monotized_data = []      while (idx < data_set.length) {    // reset value for this interval    volume = 0;    price_sum = 0;    count = 0;        // Format: time (UNIX timestamp), price, amount traded    //   timestamp: data_set[idx][0]    //   price:     data_set[idx][1]    //   volume:    data_set[idx][2]        timestamp = data_set[idx][0] + interval_length;    // get sums for this interval    while (data_set[idx][0] < timestamp) {      volume += data_set[idx][2];      price_sum += data_set[idx][1];      count++;      idx++;      if (idx >= data_set.length)        break;    }    // get average price    price = count > 0 ? price_sum / count : last_price;    last_price = price;    // add new row to monotized data array    monotized_data.push({      timestamp: timestamp,      volume: volume,      price: price    });  }}// Format: time (UNIX timestamp), price, amount traded// http://api.bitcoincharts.com/v1/csv/localbtcCAD.csv.gzvar complexCadCsv = `1363085391,42.890000000000,5.4322000000001363088879, 47.570000000000, 4.9818000000001363120475, 56.560000000000, 1.7680000000001363132522, 53.000000000000, 1.0000000000001363214378, 48.630000000000, 4.0000000000001363217281, 48.770000000000, 2.0002000000001363223157, 48.860000000000, 2.0465000000001363232051, 49.110000000000, 4.2355000000001363272551, 54.250000000000, 1.0000000000001363283662, 49.780000000000, 5.9256000000001363293072, 55.500000000000, 1.0270000000001363321440, 56.000000000000, 5.3571000000001363346950, 55.220000000000, 7.0169000000001363379555, 55.600000000000, 4.9459000000001363379607, 55.740000000000, 1.0000000000001363381362, 49.220000000000, 0.1016000000001363382662, 49.220000000000, 4.8961000000001363391161, 55.380000000000, 2.0000000000001363401704, 56.060000000000, 1.0000000000001363467393, 56.000000000000, 0.8929000000001363496639, 56.700000000000, 1.5001000000001363524530, 56.930000000000, 6.0001000000001363527377, 56.900000000000, 6.4979000000001363542700, 56.000000000000, 2.1429000000001363547113, 55.000000000000, 3.0000000000001363564084, 57.040000000000, 2.1564000000001363638453, 57.880000000000, 0.3317000000001363729323, 70.000000000000, 0.8571000000001363740718, 73.070000000000, 0.1368000000001363795449, 63.450000000000, 1.0000000000001363795494, 63.860000000000, 1.0001000000001363795603, 63.430000000000, 0.1577000000001363798700, 68.390000000000, 1.4622000000001363800835, 68.180000000000, 1.9913000000001363803497, 67.940000000000, 1.0146000000001363803790, 68.160000000000, 1.0271000000001363814790, 69.580000000000, 1.0500000000001363814810, 68.270000000000, 0.9294000000001363825583, 68.250000000000, 5.2306000000001363829358, 78.000000000000, 1.0500000000001363836583, 83.300000000000, 2.9998000000001363837642, 84.000000000000, 2.0000000000001363895966, 75.410000000000, 0.6630000000001363944788, 75.000000000000, 4.0000000000001363984884, 90.000000000000, 1.1111000000001363987472, 90.000000000000, 1.1111000000001363988438, 89.350000000000, 0.0740000000001363989586, 85.090000000000, 1.9999000000001364000191, 88.000000000000, 1.0000000000001364002717, 85.230000000000, 1.4901000000001364010104, 70.730000000000, 1.0000000000001364013267, 86.000000000000, 1.1628000000001364073182, 78.000000000000, 3.9000000000001364089933, 80.000000000000, 3.0250000000001364249509, 74.360000000000, 1.4856000000001364262262, 89.550000000000, 1.1167000000001364265293, 90.040000000000, 1.0550000000001364310351, 92.450000000000, 1.0817000000001364334487, 81.210000000000, 1.9948000000001364355951, 94.630000000000, 1.4200000000001364357864, 95.380000000000, 1.0484000000001364358542, 94.800000000000, 1.0549000000001364364067, 82.820000000000, 13.2198000000001364395451, 99.100000000000, 0.1009000000001364400184, 102.700000000000, 1.0000000000001364401183, 100.570000000000, 1.0938000000001364403945, 101.420000000000, 1.0000000000001364411110, 101.720000000000, 0.4988000000001364436263, 106.740000000000, 1.7999000000001364436873, 94.960000000000, 1.0000000000001364437451, 94.520000000000, 0.9999000000001364440483, 104.190000000000, 0.4999000000001364489123, 109.760000000000, 1.0478000000001364490688, 109.730000000000, 1.0000000000001364494732, 100.230000000000, 1.0000000000001364498537, 95.620000000000, 1.9500000000001364502332, 95.780000000000, 1.2007000000001364505883, 99.490000000000, 0.2513000000001364513250, 103.900000000000, 0.5171000000001364516343, 83.470000000000, 1.0183000000001364573738, 97.140000000000, 0.2574000000001364580938, 95.700000000000, 1.0000000000001364598407, 102.000000000000, 1.0000000000001364600233, 102.000000000000, 1.0000000000001364601641, 102.000000000000, 1.0100000000001364605133, 105.000000000000, 1.0000000000001364709921, 99.880000000000, 1.0000000000001364712798, 99.990000000000, 1.0001000000001364748894, 101.470000000000, 1.0000000000001364755340, 100.590000000000, 3.0000000000001364792969, 106.000000000000, 1.0000000000001364799933, 102.400000000000, 1.0000000000001364800923, 101.560000000000, 1.0000000000001364828813, 112.000000000000, 2.0000000000001364832014, 115.000000000000, 5.0000000000001364832308, 115.000000000000, 3.0000000000001364834249, 112.720000000000, 5.8550000000001364838578, 115.240000000000, 5.7274000000001364841672, 104.360000000000, 12.4572000000001364923361, 120.900000000000, 2.9999000000001364936087, 120.710000000000, 4.9706000000001364948998, 124.810000000000, 4.9998000000001364959661, 127.170000000000, 0.9950000000001364965648, 121.770000000000, 1.0000000000001364973827, 136.060000000000, 1.0000000000001364974001, 147.890000000000, 4.0001000000001364998794, 140.320000000000, 3.5632000000001365026364, 123.790000000000, 1.0154000000001365027711, 127.780000000000, 6.2609000000001365046987, 138.360000000000, 4.0000000000001365057275, 138.500000000000, 5.4999000000001365065898, 157.040000000000, 1.9994000000001365090058, 145.220000000000, 5.5090000000001365104881, 164.890000000000, 5.4582000000001365105565, 139.710000000000, 1.2500000000001365138055, 145.850000000000, 1.8499000000001365167322, 166.250000000000, 0.6015000000001365173858, 146.080000000000, 1.9999000000001365174283, 148.260000000000, 0.1349000000001365183486, 149.890000000000, 3.0001000000001365184905, 161.740000000000, 2.0001000000001365205476, 152.790000000000, 1.0000000000001365210365, 175.000000000000, 1.0000000000001365219395, 150.960000000000, 0.9997000000001365220927, 150.910000000000, 1.0000000000001365268452, 153.390000000000, 0.6520000000001365272285, 170.000000000000, 1.0000000000001365274795, 170.000000000000, 1.0000000000001365278764, 170.000000000000, 1.0000000000001365278930, 154.030000000000, 0.5194000000001365280374, 170.000000000000, 1.0000000000001365281909, 154.560000000000, 0.6500000000001365283450, 170.000000000000, 1.0000000000001365287835, 170.000000000000, 1.5412000000001365303267, 153.940000000000, 3.5001000000001365312742, 155.620000000000, 0.1285000000001365325139, 161.570000000000, 3.0000000000001365349680, 169.230000000000, 2.0000000000001365354798, 138.110000000000, 1.0100000000001365356226, 180.190000000000, 1.6649000000001365362290, 174.010000000000, 0.2873000000001365377549, 173.640000000000, 2.0000000000001365379774, 175.010000000000, 1.0000000000001365384562, 179.980000000000, 2.2225000000001365396478, 183.290000000000, 2.0000000000001365434139, 203.850000000000, 0.0981000000001365434614, 208.360000000000, 1.0000000000001365437520, 197.620000000000, 2.0000000000001365440837, 195.520000000000, 4.0000000000001365449254, 197.610000000000, 4.0000000000001365467994, 202.160000000000, 2.9905000000001365469985, 202.160000000000, 1.5002000000001365478982, 206.360000000000, 0.9977000000001365479416, 206.220000000000, 1.0000000000001365479554, 203.290000000000, 1.0000000000001365486039, 207.860000000000, 0.4653000000001365500973, 219.210000000000, 2.2809000000001365518766, 228.930000000000, 1.9701000000001365518846, 225.910000000000, 0.9960000000001365520063, 229.770000000000, 0.7473000000001365521859, 235.270000000000, 3.0000000000001365521926, 235.270000000000, 0.8501000000001365524515, 240.510000000000, 3.3262000000001365524659, 235.400000000000, 0.9991000000001365526701, 238.440000000000, 1.0000000000001365527072, 242.330000000000, 2.0000000000001365527199, 240.510000000000, 1.3097000000001365529148, 251.570000000000, 1.0000000000001365537800, 265.560000000000, 1.0000000000001365542522, 305.000000000000, 1.5082000000001365542586, 305.000000000000, 1.8934000000001365551390, 335.650000000000, 0.7150000000001365554253, 265.540000000000, 1.0000000000001365558982, 284.240000000000, 1.0000000000001365563330, 306.440000000000, 0.3263000000001365566909, 310.950000000000, 0.0643000000001365578721, 338.530000000000, 1.1816000000001365606252, 273.660000000000, 1.0000000000001365610294, 281.800000000000, 2.1292000000001365612809, 265.810000000000, 2.0000000000001365618499, 262.140000000000, 1.0000000000001365628947, 250.000000000000, 1.9440000000001365629291, 253.640000000000, 1.1828000000001365642148, 151.740000000000, 2.0000000000001365642413, 141.270000000000, 2.0000000000001365678778, 188.540000000000, 3.9931000000001365703940, 148.580000000000, 4.4554000000001365716351, 151.650000000000, 0.6800000000001365717197, 136.400000000000, 1.0000000000001365717771, 122.450000000000, 1.9518000000001365724442, 124.000000000000, 2.0000000000001365773281, 117.460000000000, 1.2515000000001365773887, 121.000000000000, 1.9918000000001365776714, 122.360000000000, 2.2311000000001365795875, 114.590000000000, 1.0000000000001365796323, 115.000000000000, 2.0000000000001365798963, 106.190000000000, 2.0000000000001365802678, 106.180000000000, 1.0000000000001365804038, 111.410000000000, 1.7900000000001365810280, 109.980000000000, 1.5000000000001365811712, 115.000000000000, 2.0000000000001365813104, 109.970000000000, 1.0000000000001365816966, 165.200000000000, 3.0266000000001365819572, 150.000000000000, 1.0667000000001365820699, 128.730000000000, 1.6499000000001365823425, 124.060000000000, 3.2244000000001365826775, 150.000000000000, 1.0667000000001365877655, 150.000000000000, 2.0000000000001365878739, 159.330000000000, 2.0085000000001365884739, 150.000000000000, 4.0000000000001365888397, 150.000000000000, 3.0000000000001365956959, 150.000000000000, 5.3300000000001365961896, 140.000000000000, 0.5357000000001365979939, 142.140000000000, 1.0000000000001365991144, 128.990000000000, 2.0000000000001365993080, 150.000000000000, 1.3333000000001366014910, 135.000000000000, 4.4444000000001366022593, 149.640000000000, 0.4678000000001366044482, 123.500000000000, 3.0291000000001366045307, 119.750000000000, 1.0021000000001366048928, 119.750000000000, 0.6681000000001366055142, 109.990000000000, 0.1818000000001366062216, 109.480000000000, 1.0800000000001366065512, 100.000000000000, 0.1810000000001366085870, 88.150000000000, 1.0000000000001366085948, 91.540000000000, 0.4369000000001366097421, 74.700000000000, 10.4953000000001366129928, 96.000000000000, 2.0833000000001366130124, 99.720000000000, 4.0000000000001366133447, 99.890000000000, 1.0000000000001366135520, 103.730000000000, 1.1000000000001366138028, 95.390000000000, 1.1000000000001366144237, 69.480000000000, 1.5113000000001366145377, 75.000000000000, 2.5867000000001366155682, 89.800000000000, 2.0000000000001366158005, 88.800000000000, 1.0000000000001366158456, 89.800000000000, 1.9933000000001366164776, 94.000000000000, 2.0000000000001366173698, 102.640000000000, 1.9974000000001366198863, 103.450000000000, 1.9914000000001366211035, 102.450000000000, 2.1962000000001366218782, 94.000000000000, 3.0000000000001366225431, 94.000000000000, 2.0426000000001366233216, 214.470000000000, 1.0000000000001366318951, 108.730000000000, 0.9197000000001366387777, 129.690000000000, 1.9822000000001366394307, 135.420000000000, 0.1846000000001366413885, 134.140000000000, 0.2982000000001366551162, 136.710000000000, 0.1296000000001366553999, 140.700000000000, 2.4875000000001366620334, 137.830000000000, 0.4208000000001366671189, 107.380000000000, 1.5000000000001366684569, 141.740000000000, 1.0000000000001366686872, 142.090000000000, 1.0556000000001366687106, 142.130000000000, 1.7590000000001366746322, 148.230000000000, 3.3731000000001366825778, 159.250000000000, 0.1256000000001366903154, 166.040000000000, 1.5400000000001366903247, 168.230000000000, 0.1189000000001366906417, 165.440000000000, 1.5883000000001366906495, 166.300000000000, 1.0000000000001366912064, 164.670000000000, 2.1300000000001366914573, 164.820000000000, 0.1820000000001366978559, 143.290000000000, 1.3958000000001367001597, 144.390000000000, 1.0389000000001367002599, 165.650000000000, 1.0000000000001367024672, 142.890000000000, 0.8100000000001367027540, 144.780000000000, 1.4505000000001367027692, 146.310000000000, 2.0000000000001367029695, 143.800000000000, 0.7500000000001367034952, 143.800000000000, 3.1295000000001367043181, 143.710000000000, 2.2615000000001367085501, 141.190000000000, 1.4166000000001367100612, 155.680000000000, 1.2819000000001367182014, 170.140000000000, 1.0000000000001367182173, 169.720000000000, 1.1195000000001367186205, 170.710000000000, 1.0000000000001367275779, 153.550000000000, 1.4653000000001367289143, 198.350000000000, 6.0499000000001367323428, 197.180000000000, 7.0000000000001367331486, 155.660000000000, 1.6060000000001367348392, 189.950000000000, 5.2646000000001367351603, 146.060000000000, 2.9988000000001367356384, 188.010000000000, 7.1380000000001367364586, 167.170000000000, 0.1795000000001367364740, 191.010000000000, 7.8530000000001367378952, 165.000000000000, 1.8182000000001367423338, 142.430000000000, 3.9319000000001367446179, 133.240000000000, 2.2516000000001367457397, 131.820000000000, 1.2734000000001367474137, 129.410000000000, 0.3900000000001367506472, 125.970000000000, 0.0794000000001367517588, 112.580000000000, 4.4414000000001367534445, 116.880000000000, 0.1711000000001367562381, 108.910000000000, 0.5509000000001367591999, 106.120000000000, 0.4712000000001367595257, 104.460000000000, 0.4786000000001367599098, 144.030000000000, 1.0415000000001367604271, 99.230000000000, 2.9627000000001367625410, 103.810000000000, 2.022900000000`// Parse the multi-line CSV string above into a 2D arrayvar complexCadCsvArray = $.csv.toArrays(complexCadCsv);// jquery-csv `toArrays` are strings, needs to be number// Trim whitespace and then convert to Numbervar complexCadCsvJsArrayNumbers = complexCadCsvArray.map(row => row.map(el => Number(el.trim())));// Reduce trade times to same-sized intervalssimplifyData(complexCadCsvJsArrayNumbers);$(".new_csv").text($.csv.fromObjects(monotized_data));// ----------$(".existing_csv").append(complexCadCsvArray);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><script src="https://rawgit.com/evanplaice/jquery-csv/master/src/jquery.csv.min.js"></script><h1>New simplified CSV</h1><pre class="new_csv"></pre><h1>Existing CSV run through <a href="https://github.com/evanplaice/jquery-csv">jquery-csv</a></h1><pre class="existing_csv"></pre>

#1


2  

data_set is a string, but simplifyData() is access it as if it's an array of objects. You need to convert it first.

data_set是一个字符串,但是simplifyData()访问它就好像它是一个对象数组。你需要先转换它。

data_set = data_set.split('\n').map(line => {    var linearray = line.split(',');    return {        timestamp: parseInt(linearray[0], 10),        price: parseFloat(linearray[1]),        volume: parseFloat(linearray[2])    };});

And in your call to monotized_data.append, you have square brackets when you should have curly braces, and you should be calling push()

在对monotized_data的调用中。追加,方括号应该是花括号,应该是push()

    monotized_data.push({      timestamp: timestamp,      volume: volume,      price: price    });

function simplifyData(data_set) {  interval_length = 3600; // hourly intervals  last_price = 0;  idx = 0;    monotized_data = []      while (idx < data_set.length) {    // reset value for this interval    volume = 0;    price_sum = 0;    count = 0;        // Format: time (UNIX timestamp), price, amount traded    //   timestamp: data_set[idx][0]    //   price:     data_set[idx][1]    //   volume:    data_set[idx][2]        timestamp = data_set[idx][0] + interval_length;    // get sums for this interval    while (data_set[idx][0] < timestamp) {      volume += data_set[idx][2];      price_sum += data_set[idx][1];      count++;      idx++;      if (idx >= data_set.length)        break;    }    // get average price    price = count > 0 ? price_sum / count : last_price;    last_price = price;    // add new row to monotized data array    monotized_data.push({      timestamp: timestamp,      volume: volume,      price: price    });  }}// Format: time (UNIX timestamp), price, amount traded// http://api.bitcoincharts.com/v1/csv/localbtcCAD.csv.gzvar complexCadCsv = `1363085391,42.890000000000,5.4322000000001363088879, 47.570000000000, 4.9818000000001363120475, 56.560000000000, 1.7680000000001363132522, 53.000000000000, 1.0000000000001363214378, 48.630000000000, 4.0000000000001363217281, 48.770000000000, 2.0002000000001363223157, 48.860000000000, 2.0465000000001363232051, 49.110000000000, 4.2355000000001363272551, 54.250000000000, 1.0000000000001363283662, 49.780000000000, 5.9256000000001363293072, 55.500000000000, 1.0270000000001363321440, 56.000000000000, 5.3571000000001363346950, 55.220000000000, 7.0169000000001363379555, 55.600000000000, 4.9459000000001363379607, 55.740000000000, 1.0000000000001363381362, 49.220000000000, 0.1016000000001363382662, 49.220000000000, 4.8961000000001363391161, 55.380000000000, 2.0000000000001363401704, 56.060000000000, 1.0000000000001363467393, 56.000000000000, 0.8929000000001363496639, 56.700000000000, 1.5001000000001363524530, 56.930000000000, 6.0001000000001363527377, 56.900000000000, 6.4979000000001363542700, 56.000000000000, 2.1429000000001363547113, 55.000000000000, 3.0000000000001363564084, 57.040000000000, 2.1564000000001363638453, 57.880000000000, 0.3317000000001363729323, 70.000000000000, 0.8571000000001363740718, 73.070000000000, 0.1368000000001363795449, 63.450000000000, 1.0000000000001363795494, 63.860000000000, 1.0001000000001363795603, 63.430000000000, 0.1577000000001363798700, 68.390000000000, 1.4622000000001363800835, 68.180000000000, 1.9913000000001363803497, 67.940000000000, 1.0146000000001363803790, 68.160000000000, 1.0271000000001363814790, 69.580000000000, 1.0500000000001363814810, 68.270000000000, 0.9294000000001363825583, 68.250000000000, 5.2306000000001363829358, 78.000000000000, 1.0500000000001363836583, 83.300000000000, 2.9998000000001363837642, 84.000000000000, 2.0000000000001363895966, 75.410000000000, 0.6630000000001363944788, 75.000000000000, 4.0000000000001363984884, 90.000000000000, 1.1111000000001363987472, 90.000000000000, 1.1111000000001363988438, 89.350000000000, 0.0740000000001363989586, 85.090000000000, 1.9999000000001364000191, 88.000000000000, 1.0000000000001364002717, 85.230000000000, 1.4901000000001364010104, 70.730000000000, 1.0000000000001364013267, 86.000000000000, 1.1628000000001364073182, 78.000000000000, 3.9000000000001364089933, 80.000000000000, 3.0250000000001364249509, 74.360000000000, 1.4856000000001364262262, 89.550000000000, 1.1167000000001364265293, 90.040000000000, 1.0550000000001364310351, 92.450000000000, 1.0817000000001364334487, 81.210000000000, 1.9948000000001364355951, 94.630000000000, 1.4200000000001364357864, 95.380000000000, 1.0484000000001364358542, 94.800000000000, 1.0549000000001364364067, 82.820000000000, 13.2198000000001364395451, 99.100000000000, 0.1009000000001364400184, 102.700000000000, 1.0000000000001364401183, 100.570000000000, 1.0938000000001364403945, 101.420000000000, 1.0000000000001364411110, 101.720000000000, 0.4988000000001364436263, 106.740000000000, 1.7999000000001364436873, 94.960000000000, 1.0000000000001364437451, 94.520000000000, 0.9999000000001364440483, 104.190000000000, 0.4999000000001364489123, 109.760000000000, 1.0478000000001364490688, 109.730000000000, 1.0000000000001364494732, 100.230000000000, 1.0000000000001364498537, 95.620000000000, 1.9500000000001364502332, 95.780000000000, 1.2007000000001364505883, 99.490000000000, 0.2513000000001364513250, 103.900000000000, 0.5171000000001364516343, 83.470000000000, 1.0183000000001364573738, 97.140000000000, 0.2574000000001364580938, 95.700000000000, 1.0000000000001364598407, 102.000000000000, 1.0000000000001364600233, 102.000000000000, 1.0000000000001364601641, 102.000000000000, 1.0100000000001364605133, 105.000000000000, 1.0000000000001364709921, 99.880000000000, 1.0000000000001364712798, 99.990000000000, 1.0001000000001364748894, 101.470000000000, 1.0000000000001364755340, 100.590000000000, 3.0000000000001364792969, 106.000000000000, 1.0000000000001364799933, 102.400000000000, 1.0000000000001364800923, 101.560000000000, 1.0000000000001364828813, 112.000000000000, 2.0000000000001364832014, 115.000000000000, 5.0000000000001364832308, 115.000000000000, 3.0000000000001364834249, 112.720000000000, 5.8550000000001364838578, 115.240000000000, 5.7274000000001364841672, 104.360000000000, 12.4572000000001364923361, 120.900000000000, 2.9999000000001364936087, 120.710000000000, 4.9706000000001364948998, 124.810000000000, 4.9998000000001364959661, 127.170000000000, 0.9950000000001364965648, 121.770000000000, 1.0000000000001364973827, 136.060000000000, 1.0000000000001364974001, 147.890000000000, 4.0001000000001364998794, 140.320000000000, 3.5632000000001365026364, 123.790000000000, 1.0154000000001365027711, 127.780000000000, 6.2609000000001365046987, 138.360000000000, 4.0000000000001365057275, 138.500000000000, 5.4999000000001365065898, 157.040000000000, 1.9994000000001365090058, 145.220000000000, 5.5090000000001365104881, 164.890000000000, 5.4582000000001365105565, 139.710000000000, 1.2500000000001365138055, 145.850000000000, 1.8499000000001365167322, 166.250000000000, 0.6015000000001365173858, 146.080000000000, 1.9999000000001365174283, 148.260000000000, 0.1349000000001365183486, 149.890000000000, 3.0001000000001365184905, 161.740000000000, 2.0001000000001365205476, 152.790000000000, 1.0000000000001365210365, 175.000000000000, 1.0000000000001365219395, 150.960000000000, 0.9997000000001365220927, 150.910000000000, 1.0000000000001365268452, 153.390000000000, 0.6520000000001365272285, 170.000000000000, 1.0000000000001365274795, 170.000000000000, 1.0000000000001365278764, 170.000000000000, 1.0000000000001365278930, 154.030000000000, 0.5194000000001365280374, 170.000000000000, 1.0000000000001365281909, 154.560000000000, 0.6500000000001365283450, 170.000000000000, 1.0000000000001365287835, 170.000000000000, 1.5412000000001365303267, 153.940000000000, 3.5001000000001365312742, 155.620000000000, 0.1285000000001365325139, 161.570000000000, 3.0000000000001365349680, 169.230000000000, 2.0000000000001365354798, 138.110000000000, 1.0100000000001365356226, 180.190000000000, 1.6649000000001365362290, 174.010000000000, 0.2873000000001365377549, 173.640000000000, 2.0000000000001365379774, 175.010000000000, 1.0000000000001365384562, 179.980000000000, 2.2225000000001365396478, 183.290000000000, 2.0000000000001365434139, 203.850000000000, 0.0981000000001365434614, 208.360000000000, 1.0000000000001365437520, 197.620000000000, 2.0000000000001365440837, 195.520000000000, 4.0000000000001365449254, 197.610000000000, 4.0000000000001365467994, 202.160000000000, 2.9905000000001365469985, 202.160000000000, 1.5002000000001365478982, 206.360000000000, 0.9977000000001365479416, 206.220000000000, 1.0000000000001365479554, 203.290000000000, 1.0000000000001365486039, 207.860000000000, 0.4653000000001365500973, 219.210000000000, 2.2809000000001365518766, 228.930000000000, 1.9701000000001365518846, 225.910000000000, 0.9960000000001365520063, 229.770000000000, 0.7473000000001365521859, 235.270000000000, 3.0000000000001365521926, 235.270000000000, 0.8501000000001365524515, 240.510000000000, 3.3262000000001365524659, 235.400000000000, 0.9991000000001365526701, 238.440000000000, 1.0000000000001365527072, 242.330000000000, 2.0000000000001365527199, 240.510000000000, 1.3097000000001365529148, 251.570000000000, 1.0000000000001365537800, 265.560000000000, 1.0000000000001365542522, 305.000000000000, 1.5082000000001365542586, 305.000000000000, 1.8934000000001365551390, 335.650000000000, 0.7150000000001365554253, 265.540000000000, 1.0000000000001365558982, 284.240000000000, 1.0000000000001365563330, 306.440000000000, 0.3263000000001365566909, 310.950000000000, 0.0643000000001365578721, 338.530000000000, 1.1816000000001365606252, 273.660000000000, 1.0000000000001365610294, 281.800000000000, 2.1292000000001365612809, 265.810000000000, 2.0000000000001365618499, 262.140000000000, 1.0000000000001365628947, 250.000000000000, 1.9440000000001365629291, 253.640000000000, 1.1828000000001365642148, 151.740000000000, 2.0000000000001365642413, 141.270000000000, 2.0000000000001365678778, 188.540000000000, 3.9931000000001365703940, 148.580000000000, 4.4554000000001365716351, 151.650000000000, 0.6800000000001365717197, 136.400000000000, 1.0000000000001365717771, 122.450000000000, 1.9518000000001365724442, 124.000000000000, 2.0000000000001365773281, 117.460000000000, 1.2515000000001365773887, 121.000000000000, 1.9918000000001365776714, 122.360000000000, 2.2311000000001365795875, 114.590000000000, 1.0000000000001365796323, 115.000000000000, 2.0000000000001365798963, 106.190000000000, 2.0000000000001365802678, 106.180000000000, 1.0000000000001365804038, 111.410000000000, 1.7900000000001365810280, 109.980000000000, 1.5000000000001365811712, 115.000000000000, 2.0000000000001365813104, 109.970000000000, 1.0000000000001365816966, 165.200000000000, 3.0266000000001365819572, 150.000000000000, 1.0667000000001365820699, 128.730000000000, 1.6499000000001365823425, 124.060000000000, 3.2244000000001365826775, 150.000000000000, 1.0667000000001365877655, 150.000000000000, 2.0000000000001365878739, 159.330000000000, 2.0085000000001365884739, 150.000000000000, 4.0000000000001365888397, 150.000000000000, 3.0000000000001365956959, 150.000000000000, 5.3300000000001365961896, 140.000000000000, 0.5357000000001365979939, 142.140000000000, 1.0000000000001365991144, 128.990000000000, 2.0000000000001365993080, 150.000000000000, 1.3333000000001366014910, 135.000000000000, 4.4444000000001366022593, 149.640000000000, 0.4678000000001366044482, 123.500000000000, 3.0291000000001366045307, 119.750000000000, 1.0021000000001366048928, 119.750000000000, 0.6681000000001366055142, 109.990000000000, 0.1818000000001366062216, 109.480000000000, 1.0800000000001366065512, 100.000000000000, 0.1810000000001366085870, 88.150000000000, 1.0000000000001366085948, 91.540000000000, 0.4369000000001366097421, 74.700000000000, 10.4953000000001366129928, 96.000000000000, 2.0833000000001366130124, 99.720000000000, 4.0000000000001366133447, 99.890000000000, 1.0000000000001366135520, 103.730000000000, 1.1000000000001366138028, 95.390000000000, 1.1000000000001366144237, 69.480000000000, 1.5113000000001366145377, 75.000000000000, 2.5867000000001366155682, 89.800000000000, 2.0000000000001366158005, 88.800000000000, 1.0000000000001366158456, 89.800000000000, 1.9933000000001366164776, 94.000000000000, 2.0000000000001366173698, 102.640000000000, 1.9974000000001366198863, 103.450000000000, 1.9914000000001366211035, 102.450000000000, 2.1962000000001366218782, 94.000000000000, 3.0000000000001366225431, 94.000000000000, 2.0426000000001366233216, 214.470000000000, 1.0000000000001366318951, 108.730000000000, 0.9197000000001366387777, 129.690000000000, 1.9822000000001366394307, 135.420000000000, 0.1846000000001366413885, 134.140000000000, 0.2982000000001366551162, 136.710000000000, 0.1296000000001366553999, 140.700000000000, 2.4875000000001366620334, 137.830000000000, 0.4208000000001366671189, 107.380000000000, 1.5000000000001366684569, 141.740000000000, 1.0000000000001366686872, 142.090000000000, 1.0556000000001366687106, 142.130000000000, 1.7590000000001366746322, 148.230000000000, 3.3731000000001366825778, 159.250000000000, 0.1256000000001366903154, 166.040000000000, 1.5400000000001366903247, 168.230000000000, 0.1189000000001366906417, 165.440000000000, 1.5883000000001366906495, 166.300000000000, 1.0000000000001366912064, 164.670000000000, 2.1300000000001366914573, 164.820000000000, 0.1820000000001366978559, 143.290000000000, 1.3958000000001367001597, 144.390000000000, 1.0389000000001367002599, 165.650000000000, 1.0000000000001367024672, 142.890000000000, 0.8100000000001367027540, 144.780000000000, 1.4505000000001367027692, 146.310000000000, 2.0000000000001367029695, 143.800000000000, 0.7500000000001367034952, 143.800000000000, 3.1295000000001367043181, 143.710000000000, 2.2615000000001367085501, 141.190000000000, 1.4166000000001367100612, 155.680000000000, 1.2819000000001367182014, 170.140000000000, 1.0000000000001367182173, 169.720000000000, 1.1195000000001367186205, 170.710000000000, 1.0000000000001367275779, 153.550000000000, 1.4653000000001367289143, 198.350000000000, 6.0499000000001367323428, 197.180000000000, 7.0000000000001367331486, 155.660000000000, 1.6060000000001367348392, 189.950000000000, 5.2646000000001367351603, 146.060000000000, 2.9988000000001367356384, 188.010000000000, 7.1380000000001367364586, 167.170000000000, 0.1795000000001367364740, 191.010000000000, 7.8530000000001367378952, 165.000000000000, 1.8182000000001367423338, 142.430000000000, 3.9319000000001367446179, 133.240000000000, 2.2516000000001367457397, 131.820000000000, 1.2734000000001367474137, 129.410000000000, 0.3900000000001367506472, 125.970000000000, 0.0794000000001367517588, 112.580000000000, 4.4414000000001367534445, 116.880000000000, 0.1711000000001367562381, 108.910000000000, 0.5509000000001367591999, 106.120000000000, 0.4712000000001367595257, 104.460000000000, 0.4786000000001367599098, 144.030000000000, 1.0415000000001367604271, 99.230000000000, 2.9627000000001367625410, 103.810000000000, 2.022900000000`// Parse the multi-line CSV string above into a 2D arrayvar complexCadCsvArray = $.csv.toArrays(complexCadCsv);// jquery-csv `toArrays` are strings, needs to be number// Trim whitespace and then convert to Numbervar complexCadCsvJsArrayNumbers = complexCadCsvArray.map(row => row.map(el => Number(el.trim())));// Reduce trade times to same-sized intervalssimplifyData(complexCadCsvJsArrayNumbers);$(".new_csv").text($.csv.fromObjects(monotized_data));// ----------$(".existing_csv").append(complexCadCsvArray);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><script src="https://rawgit.com/evanplaice/jquery-csv/master/src/jquery.csv.min.js"></script><h1>New simplified CSV</h1><pre class="new_csv"></pre><h1>Existing CSV run through <a href="https://github.com/evanplaice/jquery-csv">jquery-csv</a></h1><pre class="existing_csv"></pre>