Issue with Lookup and CSV file

I have been working on a Character Sheet for an RPG that I designed. I have it in PDF, but I found that the file size was quite large and wanted to slim it down. While I have it in Excel and ODS, it would be cleaner in NBOS. Unfortunately, I am not able to copy and paste into the script area, so it leaves out the crazy var mapping that I did in the PDF. There is too much to retype, so I was hoping to use the Lookup function.

The issue I am having is that I am not able to make the Lookup (DataStore) function work. I have a csv file containing the Skill Point Cost for the Attribute and Skills listed by Rank value. I want to be able to display the total points SP spent on the sheet by looking up the Rank in relation to the correct column on the csv file and return the SP value.

example data from csv:

My ranks go in increments of .1 from -10.0 to 100.0, so there are a lot of values. I was thinking that it could be that it is a number, but when I link the field to the CSV file, a dropdown menu does list the ranks (though in a different order). So I tried creating the example in the help section, but I found that I couldn't make it work either. I was able to make the dropdown menu as before. But I wasn't able to make it pull the data. I then pulled another character sheet with csv files attached, and I noticed that some of their Lookup fields worked and some did not.

Is there a problem with the Lookup function? Is there a work around?

What I would like is to be able to use is a js function that takes selected information to extract the data from the csv through Lookup or some other function, then add extracted values together for a total number.


  • edited October 2019

    The lookup works well, see attached file(example using a Datastore Lab4.csv with your format).But the sorting is problematic, the dropdown is sorted as text, meaning that it will look weird for number running from negative to positive.

    PS Large filesize for the PDF-version? Using Scribus I am guessing?

  • The PDF version I made was done using PDF Architect. It works great in that program, but runs into issues in Adobe Reader.

    After playing around with your example and linking it up to my file, I was able to get it to work perfectly. Very good example, very helpful. I am not sure where I was messing up, but in following your example was able to make it work.


    It looks like I was making the x part of the lookup equal to the fieldname I was trying to look up instead of the datastore

    Also an interesting note, if you have the CSV file open while you're running the program it will not pull data from the CSV file. I noticed that when I ran it once and it worked, opened the CSV file to look at the data, then tried it again and it wouldn't work. I suspect I may have had the CSV file open while working on the program as well.

    Making the lookup fields equal to a blank field not linked to the datastore allows me to type in the value manually. If you don't type it in exactly, nothing will pop up. But this isn't a problem for me.

    Thank you very much. Your example was very helpful.

  • edited October 2019

    This was my final sheet. I hide some fields to do the calculations for each, then added them together. Everything works now.

  • edited October 2019

    I never tried using lookup inside JS but I suspect it does not work, as you have found out. Hidden fields would have been my solution as well

Leave a Comment