CSV file generates strange start in file

Discussion in 'Questions (Windows Mobile)' started by sunnyboyj, Dec 20, 2007.

  1. sunnyboyj

    sunnyboyj Member

    If I save a file like:
    Table1.SaveCSV ("data.csv", "," ,False)
    and I open the file there are strange things in the file:
    The three fist are:
    
    After that it's like a planned to save it for example the text 'TEXT":
    TEXT,ARTICLE
    What am I doing wrong?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    This is UTF-8 marking (BOM).
    You could usually ignore it.
     
  3. sunnyboyj

    sunnyboyj Member

    Your are probably right. There is no way to concel these first three? The problem is that my application that want to import this file can not use it because of this.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    You can use BinaryFile library to read the complete csv file except of the three first bytes and save it to a new file.
    Please tell me if you need any help.
     
  5. sunnyboyj

    sunnyboyj Member

    Would be great if you could help me with it!
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    This is the code (it is also attached):
    Code:
    Sub Globals
        
    Dim buffer(0As byte
    End Sub

    Sub App_Start
        RemoveBOM(
    "1.csv","new2.csv"
    End Sub

    Sub RemoveBOM(file,NewFile)
        FileOpen(c,
    file,cRandom)
        bin.New1(c,
    true)
        size = FileSize(
    file)-3
        
    Dim buffer(size) As byte
        bin.ReadBytes(buffer(),
    3'pass the BOM
        bin.ReadBytes(buffer(),size)
        FileClose(c)
        FileDel(NewFile)
        FileOpen(c2,NewFile,cRandom)
        bin.New1(c2,
    true)
        bin.WriteBytes(buffer())
        FileClose(c2)
    End Sub
    It creates a new file without the utf8 marking.
     

    Attached Files:

  7. sunnyboyj

    sunnyboyj Member

    Thanks, only it does not work. Maybe it's because I work with tables:

    Table1.AddRow(QT.Text,Leeg1.text,leeg2.text)
    Table1.SaveCSV("LGXVRDMU.csv", ",", False)
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    Did you try to do:
    Table1.AddRow(QT.Text,Leeg1.text,leeg2.text)
    Table1.SaveCSV("LGXVRDMU.csv", ",", False)
    RemoveBOM("LGXVRDMU.csv","NewFile.csv")
     
  9. sunnyboyj

    sunnyboyj Member

    yes I did; a get an error:
    error compiling
    bin is not a known control or object
    bin.New1(c,true)
     
  10. sunnyboyj

    sunnyboyj Member

    Never mind. Forgot to load the dll-file!
     
Loading...