I would like to get total row num first, if num meets need, will parse file from beginning, but I have known above code sample will get number but cursor is at the end of file. how to handle it?
reader := csv.NewReader(fs)
reader.ReadAll()
except for above way, can also provide other ways to get total rows if have
CodePudding user response:
Unfortunately, RFC 4180 which is implemented by csv package does not define any metadata which would keep track of total rows. Of course some applications may store such metadata but in such case you would need a custom parser for reading them.