# Python Pandas JS Equivalent

**URL:** <https://discourse.psychopy.org/t/python-pandas-js-equivalent/39248>\
**Category:** Online experiments\
**Created:** [March 21, 2024, 4:03pm UTC](https://discourse.psychopy.org/t/python-pandas-js-equivalent/39248 "2024-03-21T16:03:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![PaulaBM](https://avatars.discourse-cdn.com/v4/letter/p/13edae/32.png) [@PaulaBM](https://discourse.psychopy.org/u/PaulaBM)\
**Post date:** [March 21, 2024, 4:03pm UTC](https://discourse.psychopy.org/t/python-pandas-js-equivalent/39248/1 "2024-03-21T16:03:28Z")

</div>

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:)

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [March 21, 2024, 7:54pm UTC](https://discourse.psychopy.org/t/python-pandas-js-equivalent/39248/2 "2024-03-21T19:54:55Z")

</div>

This recent post might help.

> [@Adding code to Builder for the first time to accomplish randomization of stimuli](https://discourse.psychopy.org/t/adding-code-to-builder-for-the-first-time-to-accomplish-randomization-of-stimuli/39243):
>
> I have an experiment I made with Builder that runs well, but I need to be able to randomize two sets of image stimuli separately for each trial. I have read many of the previous posts on this subject and followed a tutorial online. I wrote some code but you will see below I am getting error messages. The images are posters and faces presented sequentially – I simply want Poster A to not always be presented with Face A simply because they are in the same row -ie, randomize each column independen…

---

<div class="post-metadata">

**Author:** ![PaulaBM](https://avatars.discourse-cdn.com/v4/letter/p/13edae/32.png) [@PaulaBM](https://discourse.psychopy.org/u/PaulaBM)\
**Post date:** [March 22, 2024, 9:09am UTC](https://discourse.psychopy.org/t/python-pandas-js-equivalent/39248/3 "2024-03-22T09:09:21Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![PaulaBM](https://avatars.discourse-cdn.com/v4/letter/p/13edae/32.png) [@PaulaBM](https://discourse.psychopy.org/u/PaulaBM)\
**Post date:** [March 22, 2024, 11:35am UTC](https://discourse.psychopy.org/t/python-pandas-js-equivalent/39248/4 "2024-03-22T11:35:36Z")

</div>

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”);
