Instructions: " It worked. Instead of printing the content, you can pipe that output into a while loop so you can go through the rows one at a time. It looks like this:
cat courses.csv | while read MAJOR COURSE
do
<STATEMENTS>
done
Each new line will be read into the variables, MAJOR and COURSE. Add the above to your cat command. In the STATEMENTS area, use echo to print the MAJOR variable."
I have tried both the suggested code, which truncates the the major, and a revised code which removes the truncation. However, neither option allows me to proceed.
cat courses.csv | while read MAJOR COURSE
do
echo "$MAJOR"
done
cat courses.csv | while IFS=, read -r MAJOR COURSE
do
echo "$MAJOR"
done
Thanks for the quick reply, and appreciate the warm welcome! Unfortunately, using IFS=“,” did not solve the problem. The suggested solution (while read MAJOR COURSE) doesn’t print the full major, and using IFS seems to dissatisfy the check as well (although this allows the full major to print)
This is the output created when I input exactly what the second hint tells me to do.
To pass the level, I’m assuming it is looking for the code explicitly given in the hint (below). As shown in the screenshot above, it states “the whole loop should look like this”. However, this code does not generate the desired output (i.e. the non-truncated major names). My code above, using IFS, with or without quotations around the comma, generate the desired output, but does not pass the exercise.
cat courses.csv | while read MAJOR COURSE
do
echo $MAJOR
done
I understand that coding is a lot of banging your head into the wall to find a simple error, but at what point is this an issue with the lesson? I believe the default behavior is to truncate based on whitespaces, so the solution given in the “Hints” will not yield the correct output, and the lesson will not accept a solution that uses the internal field separator to specify the comma
Okay so at the CodeRoad screen of the project. Hit reset button it looks like multiple times? Or just hit reset once and then run the rest of the way? We still have to do the first exercise?