Read a file without no spaces


(komal ) #1

How to read any file say log file to get some meaningful information if all the spaces are removed from it?
For example, read this sentence as “Iamastudentofgolang” , “I am a student of go lang”


(Yamil Bracho) #2

You can use

 b, err := ioutil.ReadFile("file.txt") // just pass the file name
    if err != nil {
        fmt.Print(err)
    }

    fmt.Println(b) // print the content as 'bytes'

    str := string(b) // convert content to a 'string'

(George Calianu) #3

I guess you can’t.


(Inanc Gumus) #4

You can use Standard Library’s suffixarray for that. You need an algorithm though. Create a bunch of variations, then try to match them using an English dictionary. Or if you’re curious, use deep learning or something :slight_smile:


(system) closed #5

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.