Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Can we insert text from CSV?

More
1 week 4 days ago #266814 by VitoV
Can we insert text from CSV? was created by VitoV
Please help us help you and fill where relevant:
Your LimeSurvey version: 6.5.5
Own server or LimeSurvey hosting: hosting
Survey theme/template:
==================
Hi everyone,

I am looking for a solution to insert text from CSV based on the respondent's answer. We planned to work on a multi-phase survey and we want to customize some questions based on earlier choices of the respondent. I know this is possible if we use the access code(/token) and carry on the response record but it is not an option as we want to avoid sending emails to the respondent directly. Instead, I want to ask if it is possible to upload a CSV to the LimeSurvey resources, and then ask the respondents to provide their email in Q1. Based on their email, look for what they have chosen in the CSV and insert that value to Q2.
so say I have a CSV:
email, ans
g@gmail.com, red
b@gmail.com, blue
....
if a respondent answered g@gmail.com in Q1, I want to ask in Q2 'So you picked red as your favorite color last week, have it changed?'. Is this possible? 
Many thanks

Please Log in to join the conversation.

More
1 week 3 days ago #266818 by bebehuhu
Replied by bebehuhu on topic Can we insert text from CSV?
Same question as me. It would be convient if we can use the csv data uploaded to the resource tab.

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 week 3 days ago #266819 by tpartner
Replied by tpartner on topic Can we insert text from CSV?
You can only access data from a CSV file via a JavaScript AJAX call.

Search the forum for "AJAX" and "jquery-csv".

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
1 week 1 day ago #266839 by DenisChenu
Replied by DenisChenu on topic Can we insert text from CSV?
You can do it via an expression too, but how many email you have ?

Create a equiation question and for expression : you put
{if(Q01.NAOK=="g@gmail.com","red")}
{if(Q01.NAOK=="b@gmail.com","blue")}

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 week 1 day ago - 1 week 1 day ago #266847 by Joffm
Replied by Joffm on topic Can we insert text from CSV?
Hi,
you obviously want to change/edit/update this csv-file during fieldwork.
Though I do not see any difference in adding lines to the csv file or adding an expression in the survey
here is a solution.

I use the script "Papaparse.js"
Here my csv-file:
email,color
email1@example.org,red
email2@example.org,blue
email3@example.org,yellow


In a question of type "short text" (or "multiple short text", if you want to capture and show more attributes) I entered the email address as default answer.
And this script
Download the library or enter fron cdn.
Code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.4.1/papaparse.js" ></script>

Code:
<script type="text/javascript" charset="utf-8">
  $(document).on('ready pjax:complete',function() {
 
      var email=$('#question{QID} input[type="text"]').val();
 
      Papa.parse("https://www.myserver.com/test.csv", {
          download: true,
          header: true,
          skipEmptyLines: true,
          complete: function(results) {
              for (i=0; i < results.data.length; i++) {
                  if (results.data[i].email==email) {
                      $('#question{QID} input[type="text"]').val(results.data[i].color);
                      break;
                  }
              }
          }
      });
  });
</script>[/i][/i]


Now you can show the content of the text question in your further survey.
 
 

   

Joffm
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 1 week 1 day ago by Joffm.
The following user(s) said Thank You: DenisChenu

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose