Convert a CSV Line to a List in Scratch

Welcome back to Scratch 101! In this lesson we will be converting a line from a CSV file (comma-separated value) into a Scratch list utilizing a quick data conversion program.

Objective: Learn how to utilize conditionals, iteration, string operations and lists to convert one data type to another data type.

Final Product: The reason why CSV files are called "comma-separated" is because the data is separated by comments as shown in the screenshot below.

Example CSV file
This represents the general structure of a CSV file: the top line contains headers defining each parameter and then each line afterwards contains the data for these parameters for each subject/individual within the dataset. This kind of 2D storage is extremely important and matrices form the basis of complex data science.

Final Program GUI (Graphical User Interface).
The program you will create takes a line of "CSV-input" and splits each piece of data into a single Scratch list as shown in the screenshot above.

Graphical Template: https://scratch.mit.edu/projects/398509123/

Scripts:


Testing: Here is some sample data that you can utilize to test our your program:

clientid,date,weekdays,gains,prices,up

1951,3173,26.56,0.7,19.76,0.98,1

0.00,0.25,-1.27,0.28,2.00,-0.61

"YEAR","WORLDCONSUMPTION","COPPERPRICE","INCOMEINDEX","ALUMPRICE","INVENTORYINDEX","TIME"

It's always important to utilize real testing data in order to debug your program. These sets are small enough where you could make the list yourself so you'll be able to spot any mistakes pretty quickly!

Completed ProgramLink


1 comment:

  1. In this Scratch project, we'll tackle converting a single line of data from a CSV file (comma-separated values) into a list. We'll use Scratch's built-in blocks for string manipulation, looping, and working with lists to achieve this. By the end, we'll have a best discussion board post writing services program that can break down a CSV line with commas separating the values and store each piece of data as an item within a list!

    ReplyDelete