/sheets-to-forms

This JavaScript script automates the process of populating a Google Form from data stored in a Google Sheet, making it ideal for conducting surveys or creating artificial intelligence-driven surveys.

Primary LanguageJavaScript

The importCSVDataToForm function is a Google Apps Script function designed to import data from a CSV file into a Google Form programmatically. It automates the process of populating form responses from a spreadsheet containing CSV data.

How It Works

The function reads data from a CSV file, assumes the first row contains column headings, matches the column headings to the form items, and creates form responses accordingly. It supports various item types such as text, multiple choice, etc.

Usefull for MBA students to fill the form

Usage

  1. Ensure you have a Google Form created and obtain its ID.
  2. Open the Google Apps Script editor for your Google Sheets document.
  3. Copy and paste the importCSVDataToForm function into the script editor.
  4. Replace 'GOOGLE_FORM_ID' with the ID of your Google Form.
  5. Run the function importCSVDataToForm.

Supported Item Types

The function currently supports the following item types:

  • Text
  • Multiple Choice

Handling Empty Cells

The function handles empty cells in the CSV data by skipping them and logging a message to the console.

Error Handling

Errors that occur during form submission are caught and logged to the console.

Limitations

  • Currently, only text and multiple-choice item types are supported. Additional item types can be added as needed.
  • The function assumes that the CSV data matches the form structure. Any mismatch may lead to unexpected behavior.