Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


CSV file generates strange start in file


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-20-2007, 11:23 AM
Junior Member
 
Join Date: Dec 2007
Posts: 32
Default CSV file generates strange start in file

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?
Reply With Quote
  #2 (permalink)  
Old 12-20-2007, 11:27 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 2,956
Default

This is UTF-8 marking (BOM).
You could usually ignore it.
Reply With Quote
  #3 (permalink)  
Old 12-20-2007, 01:34 PM
Junior Member
 
Join Date: Dec 2007
Posts: 32
Default

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.
Reply With Quote
  #4 (permalink)  
Old 12-20-2007, 01:46 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 2,956
Default

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.
Reply With Quote
  #5 (permalink)  
Old 12-20-2007, 02:51 PM
Junior Member
 
Join Date: Dec 2007
Posts: 32
Default

Would be great if you could help me with it!
Reply With Quote
  #6 (permalink)  
Old 12-20-2007, 03:50 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 2,956
Default

This is the code (it is also attached):
Code:
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.
Attached Files
File Type: zip RemoveBOM.zip (3.1 KB, 13 views)
Reply With Quote
  #7 (permalink)  
Old 12-20-2007, 06:32 PM
Junior Member
 
Join Date: Dec 2007
Posts: 32
Default

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)
Reply With Quote
  #8 (permalink)  
Old 12-20-2007, 06:47 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 2,956
Default

Did you try to do:
Table1.AddRow(QT.Text,Leeg1.text,leeg2.text)
Table1.SaveCSV("LGXVRDMU.csv", ",", False)
RemoveBOM("LGXVRDMU.csv","NewFile.csv")
Reply With Quote
  #9 (permalink)  
Old 12-21-2007, 08:02 PM
Junior Member
 
Join Date: Dec 2007
Posts: 32
Default

yes I did; a get an error:
error compiling
bin is not a known control or object
bin.New1(c,true)
Reply With Quote
  #10 (permalink)  
Old 12-21-2007, 08:38 PM
Junior Member
 
Join Date: Dec 2007
Posts: 32
Default

Never mind. Forgot to load the dll-file!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help File bdiscount Questions & Help Needed 2 01-13-2008 04:46 PM
Setting an .EXE B4P file to run from WM5 start menu. burd27 Questions & Help Needed 1 01-06-2008 12:14 PM
Add .ico to ppc file eg .dll taximania Questions & Help Needed 2 01-02-2008 11:06 AM
Strange characters pmu5757 Questions & Help Needed 2 09-30-2007 08:56 AM
CAB File jorgerhv Questions & Help Needed 1 05-16-2007 05:46 AM


All times are GMT. The time now is 02:59 PM.


Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0