Compare commits
2 Commits
1f43111e01
...
ef692e8838
Author | SHA1 | Date |
---|---|---|
luna | ef692e8838 | |
Charlotte Som | b4cec3b138 |
12
index.js
12
index.js
|
@ -3,17 +3,22 @@ const fs = require('fs');
|
||||||
const csvData = fs.readFileSync("data.csv", "utf-8");
|
const csvData = fs.readFileSync("data.csv", "utf-8");
|
||||||
|
|
||||||
function parseRows(data) {
|
function parseRows(data) {
|
||||||
let lines = data.split(",");
|
let lines = data.split("\n");
|
||||||
let headers = lines.shift().split(",");
|
let headers = lines.shift().split(",");
|
||||||
|
|
||||||
const out = [];
|
const out = [];
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
|
if (!line)
|
||||||
|
continue;
|
||||||
|
|
||||||
const row = line.split(",");
|
const row = line.split(",");
|
||||||
const moves = [];
|
const moves = [];
|
||||||
for (let i = 0; i <= 7; i++) {
|
for (let i = 0; i <= 7; i++) {
|
||||||
moves.push(row[headers.indexOf(`step_${i}_moves`)]);
|
let step = row[headers.indexOf(`step_${i}_moves`)];
|
||||||
}
|
step = step.replace(/^[xyz]2 /, "");
|
||||||
|
|
||||||
|
moves.push(step);
|
||||||
|
}
|
||||||
|
|
||||||
out.push({
|
out.push({
|
||||||
scramble: row[headers.indexOf("scramble")],
|
scramble: row[headers.indexOf("scramble")],
|
||||||
|
@ -22,4 +27,5 @@ function parseRows(data) {
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(JSON.stringify(parseRows(csvData)));
|
console.log(JSON.stringify(parseRows(csvData)));
|
Loading…
Reference in New Issue