go - Golang, csv.writer.write 20k rows into CSV freeze my PC -


i have issue on linux ubuntu 1.4.2, not sure how sort:

func main() {         dir, _ := filepath.abs(filepath.dir(os.args[0]))         outputfile, outputerror := os.openfile(dir+"/out1.csv",                 os.o_wronly|os.o_create, 0666)         if outputerror != nil {                 fmt.printf("an error occurred file creation\n")                 return         }         defer outputfile.close()         writer := csv.newwriter(outputfile)         results := getresults()         _, result := range results {                 writer.write([]string{result.item, result.price, result.shipping})         }         writer.flush() } 

when results 1000+ records pc freezes seconds , when it's 20k, freezes minutes. how solve such issue in proper way? though flush every n records, , add time.sleep – looks awkward…


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -