A suggestion. In homework 1 you set up a system for being able to use VSC on you local machine to work with files on the lab machines. Use that system. In particular, create a new directory within the 245 directory you created in homework 1, presumably called something like "HW2".
Through this assignment you will be building a series of programs that hold information about rocket launches. A description of the columns in this data is given in the following table.
Column number | id | type | description |
---|---|---|---|
1 | identifier | string | a unique id |
2 | something | floating point number | I have no idea what this means |
3 | year | integer | the year |
4 | month | integer | month 1==January, etc |
5 | day | integer | day of month. First day of month is 1 |
6 | vehicle | string | the type of rocket |
7 | variant | string | The variant of the rocket -- for instance, how many boosters does it have |
8 | flight | string | A descriptor of the flight. Often unintelligible. |
9 | mission | string | A descriptor of the mission. Often unintelligible. |
10 | launch site | string | The location of the rocket launch |
11 | launchpad | string | the place within the location |
12 | apogee | integer | max distance from earth |
13 | category | string | I am sure that this is meaningful, just not to me. |
'1957-A166',2435849.50,1957,01,11,'Polaris FTV-4','-','Thrust reversal test','-','PM','',10,'Test' '1949-A07',2433000.13,1949,03,24,'Aerobee RTV-N-8','-','A12','-','USN49A','',5,'Ionosphe' '2018-S18',2458203.68,2018,03,26,'Nudol','-','-','GVM','GIK-1','39A',500,'-'Just hard code this data into your program. Store the instances of structs you created in 3 different variables (ie, a, b and c). A couple of things to hard code this data. First, use double quotes rater than single quotes to denote strings. Second, '-' indicates that there in no information.Rather than putting a - into your struct instances, leave these values unassigned. Similarly, '' indicates that there is no data. Leave these unassigned as well.
01-11-1957 Polaris FTV-4 Test 2435859.50 03-24-1949 Aerobee RTV-N-8 Ionosphe 2433005.13That is, you string method should create a string with the following information
/home/gtowell/Public/CS245/HW2/hl.csvRead the contents of this CSV file into structs that are stored in a slice. I strongly recommend reading the CSV file using packages supplied with the Go language. (Note there are some unofficial; packages that might allow you to marshall the CSV file directly into structs. You may try to use these, but I do not recommend it.) Here is an example program for reading a CSV file:
package main import ( "encoding/csv" "fmt" "os" ) func main() { // os.Open() opens specific file in // read-only mode and this return // a pointer of type os.File file, err := os.Open("the.csv") // Checks for the error if err != nil { fmt.Printf("Error while reading the file %v\n", err) } // Closes the file defer file.Close() // The csv.NewReader() function is called in // which the object os.File passed as its parameter // and this creates a new csv.Reader that reads // from the file reader := csv.NewReader(file) // ReadAll reads all the records from the CSV file // and Returns them as slice of slices of string // and an error if any records, err := reader.ReadAll() // Checks for the error if err != nil { fmt.Println("Error reading records") } // Loop to iterate through // and print each of the string slice for _, eachrecord := range records { fmt.Println(eachrecord) }I largely copied this program from https://www.geeksforgeeks.org/how-to-read-a-csv-file-in-golang/. There is a little more explanation on this page.
Use your Print function -- from part 1 -- to confirm that you are reading this file correctly.
Your submission will be handed in using the submit script.
If you write your program on computers other than those in the lab, be aware that your program will be graded based on how it runs on the department’s Linux server, not how it runs on your computer. The most likely problem is not submitting everything or hard coding file locations that are not correct on the Linux servers.The easiest place to write your readme is within VSC. Make a file just like a code file but name it README.txt (or just README) then just write in it. You should start by copying the sample readme. Put the README file into the HW2 directory.
These directions assume that you followed the suggestions above and have a directory named HW2 inside a 245 directory on the UNIX servers.
scp report2.pdf lab186:245/HW2
/home/gtowell/bin/submit -c 245 -p 2 -d HW2This says to submit for project 2 (-p) everything in the directory HW2 (-d) for the class 245 (-c). You should see listing of all the files you submitted and a message that says "success".
The submission should include the following items:
Again: Once you have everything you want to submit in the HW2 directory within /home/YOU/245/