Python Pandas JS Equivalent

Hello,

I have successfully programmed an experiment that required reading in an excel sheet (I’m unable to do this with the builder due to the nature of the experiment).

In python I was able to use the pandas library to read in an excel sheet and the study works perfectly. However, JS does not use pandas and thus I’m unable to make it online compatible.

What is the JS alternative to using pandas/reading in an excel doc?

Here is the current JS code:

import * as pd from ‘pandas’;
df = pd.read_excel(“fillers.xlsx”);
fillerText = df[“FillerSentence”].tolist();
fillerCorrect = df[“FillerCorrect”].tolist();
nfillerRep = [1, 3, 2, 3, 3, 2, 2, 2, 2, 4, 4, 2, 5, 5, 3, 4, 1, 5, 1, 5, 4, 3, 4, 3, 4, 5, 1, 4, 1, 1, 2, 1];
trialCount = 0;
Math.random.shuffle(fillerText);
Math.random.shuffle(nfillerRep);
currentfiller = 0;
condNumber = Math.random.randint(1, 4);
conditionFile = ((“pt_sentences” + condNumber.toString()) + “.xlsx”);

Any help would be very appreciated:)

This recent post might help.

Thank you!

I have tried the following code but I’m getting a “403 Forbidden nginx” error when trying to pilot on Pavlovia. Have you come across this issue before?

npm init -y;
npm install xlsx;
var XLSX = require(‘xlsx’);
var workbook = XLSX.readFile(“fillers.xlsx”);
let worksheet = workbook.Sheets[workbook.SheetNames[0]];
for (let index = 2; index < 93; index++) {
const FillerSentence = worksheet[L${index}].v;
const FillerCorrect = worksheet[M${index}].v;
console.log({
FillerSentence: FillerSentence, FillerCorrect: FillerCorrect
})
}

fillerText = FillerSentence.tolist();
fillerCorrect = FillerCorrect.tolist();
nfillerRep = [1, 3, 2, 3, 3, 2, 2, 2, 2, 4, 4, 2, 5, 5, 3, 4, 1, 5, 1, 5, 4, 3, 4, 3, 4, 5, 1, 4, 1, 1, 2, 1];
trialCount = 0;
shuffleArray(fillerText);
shuffleArray(nfillerRep);
currentfiller = 0;
condNumber = Math.floor(Math.random() * 4) + 1;
conditionFile = ((“pt_sentences” + condNumber.toString()) + “.xlsx”);