CSV file generates strange start in file

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?
 

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.
 

Erel

Administrator
Staff member
Licensed User
This is the code (it is also attached):
B4X:
Sub Globals
    Dim buffer(0) As 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.
 

Attachments

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)
 
Top