Welcome to the LimeSurvey Community Forum

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

CSV file automatic import

  • tesnime_haouach
  • tesnime_haouach's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 weeks 9 hours ago #271147 by tesnime_haouach
CSV file automatic import was created by tesnime_haouach
Hello,Is it possible to import a CSV file automatically uploaded by another tool into the LimeSurvey database to automate the sending of a daily survey?

Thank you!

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 weeks 8 hours ago #271149 by Joffm
Replied by Joffm on topic CSV file automatic import
What is the content of this csv file?

And why didn't you answer the questions at the beginning?

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • tesnime_haouach
  • tesnime_haouach's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 weeks 8 hours ago #271150 by tesnime_haouach
Replied by tesnime_haouach on topic CSV file automatic import
The CSV file contains information about survey participants—specifically, users who have had an incident resolved. Since new incidents are typically resolved each day, we would like LimeSurvey to automatically send out a survey to these users by importing the CSV file automatically on a daily basis.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 weeks 4 hours ago #271151 by Joffm
Replied by Joffm on topic CSV file automatic import
Ah, you talk about participants.

I see two solutions.
1. Use the API
[url] www.limesurvey.org/manual/RemoteControl_2_API [/url]
and
[url] api.limesurvey.org/classes/remotecontrol-handle.html [/url]

with the functions
add_participants()
and
invite_participants()

Create a script in your preferred programming language
  • parse the csv file
And for each row
  • add the participant
  • invite the participant

2. Use direct access to the database.
Add the new participants to table "lime_token:[surveyID]"
Invite the participants with some mailmerge add-on of a mail programm  (like "Mail Merge" in Thunderbird)

But you still did not answer the initial questions about your version, about the hosting (own server, SaaS, or ...)

Joffm
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 weeks 5 days ago #271172 by tpartner
Replied by tpartner on topic CSV file automatic import

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.

  • tesnime_haouach
  • tesnime_haouach's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
2 weeks 5 days ago #271174 by tesnime_haouach
Replied by tesnime_haouach on topic CSV file automatic import
Thank you for your reply.

I'm hosting it on my own server, [url=http://localhost:8080/index.php/admin/user/sa/personalsettings#modalSystemInformation]Version 6.15.1 [/url]

My goal is to import a CSV file and have LimeSurvey automatically determine which survey to send to each participant based on the type of incident. Do you think this is possible to achieve?

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 weeks 5 days ago - 2 weeks 5 days ago #271176 by Joffm
Replied by Joffm on topic CSV file automatic import
Yes,
you got the sample.
The only remaining thing is to parse the csv file and to determine which survey.
1. parsing
Code:
...
$csvArray = array_map('str_getcsv', file('participants.csv'));
$length = count($csvArray);
for ($i=1; $i<$length; $i++)
{
  $firstName =  $csvArray[$i][0];
  $lastName = $csvArray[$i][1];
  $email = $csvArray[$i][2];
  $language = 'en';
 
  // the survey to process
  $iSurveyID=$csvArray[$i][3];
 
  $atokenParams = array("email"=>$email,"lastname"=>$lastName,"firstname"=>$firstName,"language"=>$language,"emailstatus"=>"OK");
  $aParticipantData=array($atokenParams);
  $bCreateToken = true;
....


With this csv file
Code:
firstname,lastname,email,surveyID
Adalbert,Ameise,mail1@example.org,434736
Berta,Biber,mail2@example.org,287114
Carlo,Chinchilla,mail3@example.org,288954
Doris,Dachs,mail4@example.org,434736
Emil,Eidechse,mail5@example.org,288954


2. which survey to select
You see in the csv file I entered the resp. surveyID.
You also can set only a special sign for the type of incident and select the survey with an IF


And you want to run this from "localhost"? Do these participants have access to your local computer?

Joffm
 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 2 weeks 5 days ago by Joffm.
The following user(s) said Thank You: tpartner

Please Log in to join the conversation.

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
2 weeks 4 days ago #271200 by holch
Replied by holch on topic CSV file automatic import

http://localhost:8080/index.php/admin/user/sa/personalsettings#modalSystemInformation


This looks like a local test environment. It might be obvious (in this case please ignore), but you need to make sure that this localhost is accessible from outside so that others can respond your survey. Just mentioning it, because we have seen cases in the forum already that have installed a local test environment on their computer, just to notice that this won't work when going live.

Help us to help you!
  • Provide your LS version and where it is installed (own server, uni/employer, SaaS hosting, etc.).
  • Always provide a LSS file (not LSQ or LSG).
Note: I answer at this forum in my spare time, I'm not a LimeSurvey GmbH employee.

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose