Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Help using a library bundled up with OSWeb: csv-parse

Hi there,

In my quest to find a way to use csv files as a source for loops in OSWeb, I've been investigating different possible avenues. I just found out that OS includes a series of Javascript libraries, among which one called csvParse:

This sounds really exciting to solve my problem, but I just can't seem to get it to work. I tried the code appearing on the page above (I used a different csv file, but I made sure that file was in the pool):

const conditions = csvParse(
    {columns: true}

I ran that in my browser but get an error message saying that csvParse is not defined. So I guess I somehow have to tell OS to load up some library I want to call csvParse. So I consulted the link appearing on the OS website: and I tried preceding the above code with:

const csvParse = require('csv-parse/lib/sync')

... but get a message saying that "require" is not defined.

I thought it might be because I ran it in my browser from OS (though the documentation indicates that the csv-parse is a library bundled up with OSWeb, so that it should run fine when running my task in the browser from OS - perhaps my installation did not include it? How can I check?. So, instead I tried to run the task through JATOS (I run JATOS on my university's server). But I got the same error message. Searching the server, I could not locate anything that looks like the 'csv-parse" library. So I thought that maybe it's because the library is not actually included with JATOS. I therefore installed it on my server ("npm intall csv"). I located the sync library on my server and updated my code:

const csvParse = require('node_modules/csv-parse/lib/sync')

Here is the location of the sync.js on my server. Is the path above correct? There was an error displaying this embed.

Here is the OS task I tried:

I was wondering whether anybody out there could confirm whether my code is correct and a sample task that does work in OS when run through the browser, might why I get a "require" not defined error message and how to solve that, and whether I actually need to worry about installing csv-parse on my server etc...

Any help would be really appreciated! Thanks!


Buy Me A Coffee


  • Hi @Fab ,

    This functionality is only available as of OSWeb 1.4. I suspect that you're using OSWeb 1.3. Is that correct?

    You can get OSWeb 1.4. either by downloading the latest prerelease of OpenSesame 3.3.10 (which is what I would do), or by updating the OSWeb extension specifically. See also:

    Once you've done that, you can use csvParse() directly, as shown in the docs. (You don't have to, and in fact can't, use require() in an inline_javascript item in the same that you could import a library in a Python inline_script .)

    I hope this clears things up!

    — Sebastiaan

    Buy Me A Coffee

  • Hi @sebastiaan,

    Many thanks for this! That's awesome! I just downloaded and installed the megapack for the latest prerelease of OpenSesame 3.3.10 and indeed the code works smoothly 😀.

    The latest release and OSWeb 1.4 brings some really cool new feature!: In fact, I just I read that files are now supported as a source for loop, which is awesome! Now I no longer have to work out a way around that limitation in the previous version (in fact, I even no longer have to worry about parsing csv files for this purpose!).

    I think that with this you solved not only this thread but also another two I recently posted (I added an update to these based on your reply).

    Many thanks! Really cool! 😀👍️


    Buy Me A Coffee

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games