I have a text file containing some text data I would like to read in. Unfortunately I can't find the way to do it.
Here is an example
5 4
1 2 - Yogurt
2 0 X Chicken soup
3 1 X Cheese
4 3 X Ham
2
3
4
0
The file is made of three parts. The first part is the header (first line), the second part is a list of records, and the last part is a list of unit64 values.
The header contains only two values, a uint64 followed by a unit16. The second value is the number of records and also the number of values in the third part since these numbers are the same.
A record is a unit64 value, followed by a uint16 value, followed by a single char that can only be X or -, followed by a utf-8 encoded string up to the end of line. The data has be written into the file by using fmt.Fprintf().
The third part contains uint64 values.
I've spending some hours now trying to find out how to read this data out of the text file and can't find a way.
I can only use strconv.ParseUint(str, 0, 64) or uint16(strconv.ParseUint(str, 0, 16)) if str contains only the digits belonging to the number. I looked into bufio to use the Reader but I can get at most lines. I should probably use the bufio.Scanner but I can't determine how to use it from the documentation.