Compare commits

..

No commits in common. "ef692e88383ffbb1639421d514dc0524fefd538b" and "1f43111e01d60d39d6c4ce23d92f6bca3e815386" have entirely different histories.

1 changed files with 5 additions and 11 deletions

View File

@ -3,22 +3,17 @@ const fs = require('fs');
const csvData = fs.readFileSync("data.csv", "utf-8");
function parseRows(data) {
let lines = data.split("\n");
let lines = data.split(",");
let headers = lines.shift().split(",");
const out = [];
for (const line of lines) {
if (!line)
continue;
const row = line.split(",");
const row = line.split(",");
const moves = [];
for (let i = 0; i <= 7; i++) {
let step = row[headers.indexOf(`step_${i}_moves`)];
step = step.replace(/^[xyz]2 /, "");
moves.push(step);
moves.push(row[headers.indexOf(`step_${i}_moves`)]);
}
out.push({
scramble: row[headers.indexOf("scramble")],
@ -27,5 +22,4 @@ function parseRows(data) {
}
return out;
}
console.log(JSON.stringify(parseRows(csvData)));
console.log(JSON.stringify(parseRows(csvData)));